1870. Minimum Speed to Arrive on Time
Содержание
class Solution:
def minSpeedOnTime(self, dist: List[int], hour: float) -> int:
def check(speed):
res = 0
for i, d in enumerate(dist):
res += (d / speed) if i == len(dist) - 1 else math.ceil(d / speed)
return res <= hour
r = 10**7 + 1
res = bisect_left(range(1, r), True, key=check) + 1
return -1 if res == r else res