AdvancedRating 1800
Grow Your Capital
You start with capital w and can finish at most k projects, one at a time. Project i needs capital cᵢ to start and adds profit pᵢ to your capital when done. Print the largest final capital.
Input
n, k and w; the n profits; the n capitals.
Output
One integer.
Sample 1
Input
3 2 0 1 2 3 0 1 1
Output
4
Sample 2
Input
3 3 0 1 2 3 0 1 2
Output
6
Output appears here