Maximum Performance of a Team LeetCode solution in Python
1class Solution:2def maxPerformance(3self, n: int, speed: List[int], efficiency: List[int], k: int4) -> int:5l = list(zip(efficiency, speed))6l.sort(reverse=True)7h = []8res = 09mod = 100000000710mx_sum = 011print(l)12for i in range(n):13res = max(res, (mx_sum + l[i][1]) * l[i][0])14if len(h) < k - 1:15heappush(h, l[i][1])16mx_sum += l[i][1]17elif k != 1:18x = 019if h:20x = heappop(h)21heappush(h, max(x, l[i][1]))22mx_sum = mx_sum - x + max(x, l[i][1])23return res % mod