Koko Eating Bananas

Medium
ArrayBinary SearchAmazonGoogle
Koko has n piles of bananas and h hours before the guards return. Each hour she picks one pile and eats up to k bananas from it; if the pile has fewer than k bananas she eats the whole pile and eats no more that hour. Print the minimum integer eating speed k that lets her finish every pile within h hours. Input format: - First line: n h - Second line: n integers, the pile sizes

Constraints

1 <= n <= 10^5
n <= h <= 10^9
1 <= piles[i] <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit