Find The Smallest Divisor Given A Threshold

medium
1. Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.
2. Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).
3. It is guaranteed that there will be an answer.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1 <= nums.length <= 5 * 10^4
1 <= nums[i] <= 10^6
nums.length <= threshold <= 10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4
1 2 5 9
6
Output
5
Previous
Median Of Two Sorted Arrays
Next
Chocolate Distribution

Related Questions