← 返回 amazon 的题目列表Minimum Eating Speed
类型:online_judge
Given an array piles of positive integers, where piles[i] is the number of bananas in pile i, Koko chooses exactly one pile per hour and eats at a fixed integer speed k. If the pile has fewer than k bananas, she finishes it during that hour and cannot start another pile.
Given h hours, return the minimum integer eating speed k that allows Koko to finish all piles within h hours.
Input
n h
piles[0] piles[1] ... piles[n-1]
Output
minimum integer speed k
Constraints
1 <= n <= 10^5
n <= h <= 10^9
1 <= piles[i] <= 10^9
Example
Input:
4 8
3 6 7 11
Output:
4
Example
Input
4 8
3 6 7 11
Output
4