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 |
开二维绝对ce,建议开一维#include<iostream> #include<cstring> using namespace std; int w[3501]={0}; int d[3501]={0}; int dp[13000]; int main() { int n,m; cin>>n>>m; memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) cin>>w[i]>>d[i]; for(int i=1;i<=n;i++) for(int j=m;j>=0;j--) if(j-w[i]>=0) dp[j]=max(dp[j-w[i]]+d[i],dp[j]); //else dp[i][j]=dp[i-1][j]; cout<<dp[m]<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator