小看一下hint
又是binary search
我对binary search的联想力真的很不构= =
def minimizedMaximum(self, n: int, quantities: List[int]) -> int:
def canbeDistributed(k):
cnt = 0
for q in quantities:
cnt += ceil(q/k)
return cnt<=n
l,r = 1, max(quantities)
while l<r:
mid = (l+r)//2
if canbeDistributed(mid):
r = mid
else:
l = mid+1
return l