Skip to content

Commit 3bb88a4

Browse files
committed
Time: 2502 ms (5.24%), Space: 30.7 MB (99.05%) - LeetHub
1 parent 671465d commit 3bb88a4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def maxRunTime(self, n: int, batteries: List[int]) -> int:
6+
left = 1
7+
right = sum(batteries) // n
8+
while left < right:
9+
target = right - (right - left) // 2
10+
11+
extra = 0
12+
for power in batteries:
13+
extra += min(power, target)
14+
15+
if extra // n >= target:
16+
left = target
17+
else:
18+
right = target - 1
19+
return left

0 commit comments

Comments
 (0)