2141. Maximum Running Time of N Computers
On This Page
class Solution:
def maxRunTime(self, n: int, batteries: List[int]) -> int:
l, r = 0, sum(batteries)
while l < r:
mid = (l + r + 1) >> 1
if sum(min(x, mid) for x in batteries) >= n * mid:
l = mid
else:
r = mid - 1
return l