

The first line contains an integer ‘T’ denoting the number of test cases. Then each test case follows.
The first input line of each test case contains two integers ‘N’ and ‘M’ denoting the number of battalions and tanks respectively.
The second line of each test case contains ‘N’ space-separated integers denoting the number of soldiers in ‘N’ battalions.
For each test case, return the maximum ratio of soldiers in a battalion to the number of tanks as described in the problem statement.
Your answer is considered correct if its absolute or relative error doesn't exceed 0.000001.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 50
1 <= ‘N’ <= 1000
‘N’ <= ‘M’ <= 10000
1 <= ARR[i] <= 1000000
Time limit: 1 sec
Let us first assign 1 tank to each battalion because the number of tanks assigned to any battalion will definitely be greater than or equal to 1. Now, if any extra tank is left then assigning the tank to the battalion having the maximum ratio of soldiers to the number of tanks will be an optimal choice. Because the maximum ratio will definitely decrease if we assign the next tank to this battalion. Similarly, we can do it for each remaining tank.
We can observe here that at each instance we are supposed to find the battalion having the maximum ratio. We can easily perform this task using a max-heap.
Consider the following steps:
The basic idea of this approach is to find the minimum ratio using a binary search.
Let us see how to check if a given real number (say ‘X’) is the minimum ratio(as defined in the problem statement) or not.
We will iterate through each battalion and allot a minimum number of tanks to each battalion such that the ratio of the number of soldiers to the number of tanks allotted is less than or equal to ‘X’. Now, if the sum of total allotted tanks exceeds the number of tanks given then, the minimum ratio must be greater than the chosen ‘X’. Otherwise, the minimum ratio will be either ‘X’ or less than ‘X’.
Consider the following steps: