176. Eating Speed
MediumBinary Search on Answer
There are piles of bananas. Eating at speed k bananas per hour, a pile of p takes ⌈p/k⌉ hours. Print the minimum integer k to finish all piles within h hours.
Input format
Line 1: n h Line 2: pile sizes
Output format
The minimum speed.
Example 1
Input
4 8 3 6 7 11
Output
4
Example 2
Input
5 5 30 11 23 4 20
Output
30
Constraints
1 ≤ n ≤ h ≤ 10⁹ 1 ≤ pile ≤ 10⁹
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…