Meera runs a small typing shop. She has n piles of documents, and the list piles tells how many pages each pile holds. The customer will return in h hours, and everything must be typed by then.
Meera picks one typing speed of k pages per hour and keeps it. In each hour she works on a single pile. She types up to k pages from it. If the pile has fewer than k pages left, she finishes it and rests for the rest of that hour.
She wants the slowest speed that still works. Return the smallest whole number k with which she can type every page within h hours.
Examples
Example 1:
Input: piles = [5,9,14], h = 6
Output: 5
Explanation: At speed 5 the piles take 1 + 2 + 3 = 6 hours. At speed 4 they would take 2 + 3 + 4 = 9 hours, which is too many.
Example 2:
Input: piles = [8,8,8], h = 3
Output: 8
Explanation: There is exactly one hour for each pile, so she must finish a whole pile within a single hour.
Example 3:
Input: piles = [100], h = 4
Output: 25
Explanation: One pile of 100 pages in 4 hours means 100 / 4 = 25 pages every hour.