Most capital after k projects
You start with capital w and may finish at most k projects, one after another. Project i can start only when your capital is at least capital[i] (starting it spends nothing), and it adds profits[i] to your capital when it finishes. Each project can be done at most once. Return the largest capital you can end with. All values are non-negative integers; profits and capital have the same length, which may be 0.
Aim for O((n + k) log n) instead of rescanning every project for each pick.
Besides the tests, one large input (4,000 projects, k = 4,000) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
most_capital(0, 2, [1,2,3], [0,1,1])→4most_capital(0, 3, [1,2,3], [0,1,2])→6most_capital(2, 2, [4,6,1], [3,2,0])→12