Battalions and Tanks Problem Statement
Given 'N' battalions and 'M' tanks, along with an array representing the number of soldiers in each battalion, you need to allocate the tanks such that the maximum ratio of soldiers per tank in any battalion is minimized.
The number of tanks is always assumed to be greater than the number of battalions.
Input:
The first line contains an integer 'T' indicating the number of test cases.
Each test case consists of two lines:
- The first line contains two integers 'N' and 'M', the number of battalions and the number of tanks, respectively.
- The second line contains 'N' space-separated integers representing the number of soldiers in each battalion.
Output:
For each test case, return the minimized maximum ratio of soldiers to tanks for any battalion.
The result should be accurate to within an absolute or relative error of at most 0.000001.
Example:
Suppose there is 1 test case with the following details:
Input:
T = 1
N = 3, M = 5
Soldiers[] = [10, 20, 30]
Possible Output:
Output:
6.000000
Constraints:
1 ≤ T ≤ 50
1 ≤ N ≤ 1000
N ≤ M ≤ 10000
1 ≤ ARR[i] ≤ 1000000
- Time limit: 1 sec
Note:
You only need to implement the function to return the answer, no need to handle input/output processes.
Be the first one to answer
Add answer anonymously...
Top Amazon Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Amazon Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app