2141. Maximum Running Time of N Computers

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2141

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