1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| # @Title: 完成旅途的最少时间 (Minimum Time to Complete Trips)
# @Author: 15816537946@163.com
# @Date: 2022-02-27 12:06:50
# @Runtime: 836 ms
# @Memory: 26.1 MB
class Solution:
def minimumTime(self, time: List[int], totalTrips: int) -> int:
lo = 1
hi = min(time) * totalTrips
while lo <= hi:
mid = (lo + hi) >> 1
tot = sum(mid // t for t in time)
if tot >= totalTrips:
hi = mid - 1
else:
lo = mid + 1
return lo
|