502. Ipo

class Solution:
    def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:
        # min - heap
        minCapital = [[capital[i], profits[i]] for i in range(len(profits))]
        heapq.heapify(minCapital)

        # min heap with negative values (max heap)
        maxProfit = []

        for i in range(k):
            # All project with less or eqaul required capital
            while minCapital and minCapital[0][0] <= w:
                c, p = heapq.heappop(minCapital)

                # Add all the feasible projects
                heapq.heappush(maxProfit, -p)

            if not maxProfit:
                break

            # Pop 1 with max profit
            w += -1 * heapq.heappop(maxProfit)

        return w