O81
Find the Smallest Divisor Given a Threshold
Problem Statement & Objective
Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result's ceiling. Find the smallest divisor such that the sum <= threshold.
Function Signature (Python)
smallest_divisor(nums: list[int], threshold: int) -> intInput & Output Contract
Output Rule:En küçük bölen pozitif tam sayısı.
System Constraints
1 <= sayilar.length <= 5 * 10^4
1 <= sayilar[i] <= 10^6
sayilar.length <= esik <= 10^6Example Execution Walkthrough
sayilar = [1, 2, 5, 9], esik = 6 -> bolen = 5 için:
ceil(1/5)+ceil(2/5)+ceil(5/5)+ceil(9/5) = 1 + 1 + 1 + 2 = 5 <= 6 -> cevap: 5Example Test Scenarios (3)
Example 1
Input:
[[1,2,5,9],6]Expected Output:
5Example 2: esik = n
Input:
[[44,22,33,11,1],5]Expected Output:
44Example 3: Geniş Eşik
Input:
[[21212,10101,12121],1000000]Expected Output:
1