leetcode1011】的更多相关文章

A conveyor belt has packages that must be shipped from one port to another within D days. The i-th package on the conveyor belt has a weight of weights[i].  Each day, we load the ship with packages on the conveyor belt (in the order given by weights)…
class Solution: def shipWithinDays(self, weights: 'List[int]', D: int) -> int: left = max(weights)#不能小于最重的单个货物 right = sum(weights)#不用大于全部货物的总重量 while left < right:#以此为左和右边界,向中间查询 cur = 0 #当前批次装载重量 need = 1 #所需时间 mid = (left + right) // 2 for w in w…