Smallest Divisor Problem Statement
Given an array of integers arr
and an integer limit
, your task is to find the smallest integer divisor such that dividing all elements of the array by this divisor and rounding up to the nearest integer yields a sum less than or equal to limit
.
Input:
The first line contains an integer 'T', the number of test cases.
For each test case, the following lines apply:
The first line contains an integer 'N', the size of the array.
The second line contains 'N' space-separated integers, the elements of the array.
The third line contains an integer 'limit', defining the allowed limit for the sum.
Output:
For each test case, print the smallest required divisor on a new line.
Example:
Input:
2
3
3 6 7
5
2
1 2
5
Output:
5
1
Constraints:
1 <= T <= 5
1 <= N <= 2 * (10^3)
1 <= arr[i] <= 10^3
N <= limit <= 10^4
Note:
Each result of the division should be rounded to the nearest integer greater than or equal to that element. Implement the solution; output is handled.

AnswerBot
4mo
The task is to find the smallest integer divisor such that dividing all elements of the array by this divisor and rounding up to the nearest integer yields a sum less than or equal to the given limit....read more
Help your peers!
Add answer anonymously...
>
Vymo Technologies Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

