A cafeteria monkey has found several piles of bananas.
The monkey chooses an eating speed of S bananas per hour. If a pile contains pile bananas, it takes exactly ceil(pile / S) hours to finish that pile.
The monkey eats from only one pile at a time and must finish all banana piles within H hours.
Your task is to determine the minimum integer eating speed S that allows the monkey to finish all the bananas within the given time.
Important Observation:
If the monkey can finish all piles at some speed S, then it can also finish them at any speed greater than S.
This property can be used to efficiently search for the answer.
The first line contains an integer T — the number of test cases.
For each test case:
- The first line contains two integers
NandH— the number of banana piles and the total number of hours available. - The second line contains
Nintegers representing the sizes of the banana piles.
For each test case, print a single integer representing the minimum eating speed.
Input
Output1
4 8
3 6 7 11
Explanation4
At a speed of
4 bananas per hour:
ceil(3 / 4) = 1hourceil(6 / 4) = 2hoursceil(7 / 4) = 2hoursceil(11 / 4) = 3hours
1 + 2 + 2 + 3 = 8 hours.
Example 2
Input
Output1
5 5
30 11 23 4 20
Explanation30
The monkey has exactly 5 hours to finish 5 piles, so each pile must be completed in at most one hour. The minimum speed that satisfies this requirement is
30.