Last active
December 9, 2015 23:58
-
-
Save henteko/4347527 to your computer and use it in GitHub Desktop.
SRM565 500
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MonstersValley2 { | |
public: | |
int minimumPrice(vector <int> dread, vector <int> price) { | |
int result = solve(dread, price, 0, 0, 0, dread.size()); | |
return result; | |
} | |
int solve(vector<int> d, vector<int> p, int i ,long long int sum, int sum_p, int last) { | |
if(last == i) return sum_p; | |
if(sum < d[i]) { | |
return solve(d,p,i+1,sum+d[i], sum_p+p[i],last); | |
}else { | |
return min(solve(d,p,i+1,sum,sum_p,last), solve(d,p,i+1,sum+d[i],sum_p+p[i],last)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment