#include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #include<vector> #include<utility> #include<map> #include<set> #include<queue> #include<cmath> #define INF 1000000000 using namespace std; typedef long long int int64; int main() { int h0, a0, d0; int h, a, d; int ch, ca, cd; int prespend = 0; scanf("%d %d %d", &h, &a, &d); scanf("%d %d %d", &h0, &a0, &d0); scanf("%d %d %d", &ch, &ca, &cd); if(a <= d0){ prespend = ca*(d0+1-a); a = d0+1; } int minspend = INF; for(int lx = 0; h0+2 >= a+lx-d0;lx++){ for(int ly = 0;a0+2 >= d+ly;ly++){ int aa = a+lx, dd = d+ly; int hh = (h0+aa-d0-1)/(aa-d0)*(a0-min(a0,dd)); int dh = max(hh+1, h) - h; minspend = min(lx*ca + ly*cd + dh*ch + prespend, minspend); } } printf("%d\n", (minspend == INF) ? prespend:minspend); return 0; }
2014年11月22日 星期六
Codeforces Round #278 (Div. 1), problem: (A) Fight the Monster
頗有趣的題目,Greedy 亂掃
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言