IPO
You start with w capital and can complete at most k distinct projects. Project i requires capital[i] to start and yields a pure profit[i] added to your capital when finished. Once a project is done its profit becomes available capital for later projects. Return the maximum capital you can hold after finishing at most k projects.
Open official problem prompt ↗Choose up to k projects, in some order, that leave you with the largest possible final capital, respecting that each project can only be started once you can afford its capital requirement.
A venture investor with limited cash unlocks bigger deals as returns roll in. Each round they fund the most profitable deal they can currently afford; the payoff enlarges their wallet, which opens richer deals next round.
- Input
- k = 2, w = 0, profits = [1, 2, 3], capital = [0, 1, 1]
- Output
- 4
- Why
- With w=0 only project 0 (cost 0) is affordable; finishing it gives w=1, unlocking projects costing 1. Take the profit-3 project for w=4.
1 <= k <= 10^50 <= w <= 10^91 <= profits.length == capital.length <= 10^50 <= profits[i] <= 10^40 <= capital[i] <= 10^9