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 |
dp问题!附代码!#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--) { int temp=dp[j-w]+v; if(temp>dp[j]) dp[j]=temp; } } printf("%d\n",dp[m]); return 1; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator