标签:
http://poj.org/problem?id=3624
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; int z[3405],v[3405]; int dp[12885]; int main() { int N,M; while(cin>>N>>M) { memset(dp,0,sizeof(dp)); for(int i=1; i<=N; i++) cin>>z[i]>>v[i]; for(int i=1; i<=N; i++) for(int j=M; j>=z[i]; j--) dp[j]=max(dp[j],dp[j-z[i]]+v[i]); cout<<dp[M]<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/a-clown/p/5915911.html