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 <iostream> #include <cstdio> #include <string.h> using namespace std; int dp[100110];//竟然是数组太小了,WA了好多次 struct node { int cost; int value; }s[1500]; int main() { int t,i,d,sum,year,maxf,j,k,l,sy; scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d%d%d",&sum,&year,&d); sy=sum/1000; for (i=1;i<=d;++i) { scanf("%d%d",&s[i].cost,&s[i].value); s[i].cost=s[i].cost/1000; } for (i=1;i<=year;++i) { memset(dp,0,sizeof(dp)); maxf=-1; for (j=1;j<=d;++j) for (k=s[j].cost;k<=sy;++k) { dp[k]=max(dp[k],dp[k-s[j].cost]+s[j].value); } sum=sum+dp[sy]; sy=sum/1000; } printf ("%d\n",sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator