O(klogn)
\n\n# Code\n\nclass Solution:\n    def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:\n        maxProfit = []  # onl
\n\n# Code\n```\nclass Solution:\n    def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:\n        maxProfit = []  # only projects we can afford\n        minCapital = [(c,p) for c,p in zip(capital,profits)]\n        heapq.heapify(minCapital)  # sort on the bases of capital\n\n        for i in range(k):\n            while minCapital and minCapital[0][0] <= w:\n                c,p = heapq.heappop(minCapital)\n                heapq.heappush(maxProfit,-1*p)\n\n            if not maxProfit:\n                break\n            w += -1*heapq.heappop(maxProfit)\n        return w\n\n```
['Heap (Priority Queue)', 'Python3']