Given initial capital, project profits, and project capital requirements, maximize your final capital by selecting at most k projects. Projects become available only when your current capital is large enough, so you need one heap for availability and another for the best profit choice.
k = max projects, w = initial capital, profits and capital are project arrays
maximum capital after completing at most k projects
Example 1:
Input:
k = 2 w = 0 profits = [1,2,3] capital = [0,1,1]
Output:
4
Explanation:
Take profit 1 first, then profit 3 becomes available; final capital is 4.
Example 2:
Input:
k = 3 w = 0 profits = [1,2,3] capital = [0,1,2]
Output:
6
Explanation:
Projects can be unlocked one by one as capital increases.