| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
There are n piles of bananas; pile i has ai bananas. There are H hours available. If the eating speed is k bananas per hour, then in one hour one pile is chosen and min(k, remaining in that pile) bananas are eaten; a pile that is finished early does not carry the spare time over. Pile i therefore takes ⌈ ai / k⌉ hours.
Find the smallest integer speed k ≥ 1 for which all piles can be finished within H hours, i.e. ∑i⌈ ai / k⌉ ≤ H.
The first line contains two integers n and H. The second line contains n integers a0… an − 1.
Print one integer — the minimum eating speed.
1 ≤ n ≤ 105
n ≤ H ≤ 109
1 ≤ ai ≤ 109
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|