Tap here to switch tabs
Problem
Submissions

Problem: Find the Smallest Divisor Given a Threshold

med
30 min
Try to solve the Find the Smallest Divisor Given a Threshold problem.

Statement

Given an integer array nums and an integer threshold, choose a positive integer divisor d such that the sum of each element in nums divided by d and rounded up is at most threshold.

Find the smallest positive divisor such that the sum of all rounded division results is less than or equal to threshold. Return this smallest divisor.

Note: Each division result is rounded up to the nearest integer greater than or equal to the result (i.e., its ceiling value). For example, 7 / 3 is rounded up to 3, while 10 / 2 remains 5. After rounding, all the resulting values are summed together.

Constraints:

  • 11 \leq nums.length 5×104\leq 5 \times 10^4

  • 11 \leq nums[i] 106\leq 10^6

  • nums.length \leq threshold 106\leq 10^6

Tap here to switch tabs
Problem
Submissions

Problem: Find the Smallest Divisor Given a Threshold

med
30 min
Try to solve the Find the Smallest Divisor Given a Threshold problem.

Statement

Given an integer array nums and an integer threshold, choose a positive integer divisor d such that the sum of each element in nums divided by d and rounded up is at most threshold.

Find the smallest positive divisor such that the sum of all rounded division results is less than or equal to threshold. Return this smallest divisor.

Note: Each division result is rounded up to the nearest integer greater than or equal to the result (i.e., its ceiling value). For example, 7 / 3 is rounded up to 3, while 10 / 2 remains 5. After rounding, all the resulting values are summed together.

Constraints:

  • 11 \leq nums.length 5×104\leq 5 \times 10^4

  • 11 \leq nums[i] 106\leq 10^6

  • nums.length \leq threshold 106\leq 10^6