Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
汗, 这都不知道算是怎么过的...res[i]前i周总费用. res[i] = min{c[i], c[i - 1] + 5} * y[i] + res[i - 1]; 注意每次比较了c[i], c[i - 1] + 5后要让c[i]为比较小的那个... long long res = 0; bool flag = true; for(int i = 0; i != n; ++i) { scanf("%d%d", c + i, f + i); if(flag) { res += (*(c + i)) * (*(f + i)); flag = false; } else { if(c[i] > c[i - 1] + s) c[i] = c[i - 1] + s; res += c[i] * f[i]; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator