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 |
求助,大家帮忙看哪里错了,测试了几组数据没问题,但老师WA啊!帮忙了!#include <cstdlib> #include <iostream> using namespace std; int k = 0; int c = 0; int a[1005]; int p[1005]; int dp[1005]; int find() { memset(dp, 0, sizeof(dp)); for(int i=0; i<c; i++) { dp[i] = a[i]; for(int j=0; j<i; j++) { if(dp[j] > 0) { if((dp[j]+10)*p[j] > dp[j]*p[i]) { dp[i] += dp[j]; dp[j] = 0; } } } } int sum = 0; for(int k=0; k<c; k++) { if(dp[k] > 0) { sum += (dp[k]+10)*p[k]; } } return sum; } int main() { scanf("%d", &k); while(k--) { scanf("%d", &c); for(int i=0; i<c; i++) { scanf("%d %d", &a[i], &p[i]); } printf("%d\n", find()); } system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator