Skip to content

Commit eb6e0e4

Browse files
Shouvik-99techyminati
authored andcommitted
maxPerformance.py
1 parent 52777d6 commit eb6e0e4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎maxPerformance.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int:
3+
4+
cur_sum, h = 0, []
5+
ans = -float('inf')
6+
7+
for i, j in sorted(zip(efficiency, speed),reverse=True):
8+
while len(h) > k-1:
9+
cur_sum -= heappop(h)
10+
heappush(h, j)
11+
cur_sum += j
12+
ans = max(ans, cur_sum * i)
13+
14+
return ans % (10**9+7)

0 commit comments

Comments
 (0)