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 |
return 1;?In Reply To:dp问题!附代码! Posted by:chenxuan123456789 at 2012-07-31 11:02:56 > #include <stdio.h> > #include <string.h> > #define M 14000 > int dp[M]; > int main() > { > int n,m,v,w; > memset(dp,0,sizeof(dp)); > scanf("%d %d",&n,&m); > for(int i=1;i<=n;i++) > { > scanf("%d %d",&w,&v); > for(int j=m;j>=w;j--) > dp[j]=max(dp[j],dp[j-w]+v); > } > printf("%d\n",dp[m]); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator