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
1mo

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
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter