背包 完全背包最简代码 1 for(int i=1;i<=n;++i) 2 for(int j=w[i];j<=w;++j) 3 dp[j]=max(dp[j],dp[j-w[i]]+v[i]); View Code