Skip to content

Instantly share code, notes, and snippets.

@henteko
Last active December 9, 2015 23:58
Show Gist options
  • Save henteko/4347527 to your computer and use it in GitHub Desktop.
Save henteko/4347527 to your computer and use it in GitHub Desktop.
SRM565 500
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