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 |
数组開小了会RE,貌似和题目説的数据规模不符啊開45260就會RE,理论上祘,每年至多增长10%,那麽40年后最多是1000K*1.1^40=45259K,是不會越界的。 #include <iostream> #include <stdio.h> #include <cmath> using namespace std; int main() { int N; scanf("%d", &N); for(int i = 0; i < N; i++){ int start, year; scanf("%d%d", &start, &year); int d; scanf("%d", &d); int bonds[10], it[10]; for(int j = 0; j < d; j++){ scanf("%d%d", bonds+j, it+j); bonds[j] /= 1000; } int dp[51200] = {0}; int MX = (int)((start/1000) * pow(1.1, year)) + 4; for(int j = 0; j <= MX; j++){ int resj = 0; for(int k = 0; k < d; k++){ if(j < bonds[k]) continue; int temp = dp[j-bonds[k]] + it[k]; if(temp > resj) resj = temp; } dp[j] = resj; } for(int j = 0; j < year; j++){ start += dp[start/1000]; } printf("%d\n", start); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator