MAX Heap in python


#1
import heapq
class Solution:
    def solve(self, A, B):
        heap=[-1*c for c in A]
        heapq.heapify(heap)
        s=0
        while B>0:
            d=heapq.heappop(heap)
            s+=d*-1
            heapq.heappush(heap, d+1)
            B-=1
        return s