Baseline Binary Search · In Search Space O(n log M), where M is the largest element · O(1)
A signal pipeline compresses each sample by integer division before summing the channels, and the regulator caps the combined output. A coarser divisor lowers the output but loses detail, so the team wants the smallest divisor that keeps the sum within the cap. Pick that divisor.
Input: An array nums of n positive integers and an integer threshold.
Output: The smallest positive divisor d such that the sum of ceil(nums[i] / d) over all i is at most threshold.
1 <= nums.length <= 5 * 10^41 <= nums[i] <= 10^61 <= threshold <= 10^6A valid divisor always existsInput: {"nums":[1,2,5,9],"threshold":6}
Output: 5
Divisor 4 leaves a sum of 7, while divisor 5 rounds every channel down far enough for a total of 5.
Input: {"nums":[44,22,33,11,1],"threshold":5}
Output: 44
Every sample must collapse to 1, which happens only at a divisor of 44, the largest value.