二分答案
class Solution:
def minEatingSpeed(self, piles: List[int], h: int) -> int:
l, r = 1, max(piles)
def check(k):
time = 0
for c in piles:
if c % k == 0: time += (c // k)
else: time += ( c // k + 1)
if time <= h: return True
else: return False
while l < r:
mid = (l + r) // 2
if check(mid): r = mid
else: l = mid + 1
return l