版本比较
C++算法讲解:背包DP
正文
增加 2 行删除 2 行
27 行未改动28293031323334353674 行未改动11111211311411511611711811986 行未改动27 行未改动for(int j=m;j>=w[i];j--)dp[j]=max(dp[j],dp[j-w[i]]+v[i]);cout<<dp[m];return 0;}```[AC记录](https://www.luogu.com.cn/record/237045123)## 二、完全背包:[P1616 疯狂的采药](https://www.luogu.com.cn/problem/P1616)74 行未改动for(int i=1;i<=n;i++)for(int j1=m1;j1>=w1[i];j1--)for(int j2=m2;j2>=w2[i];j2--)dp[j1][j2]=max(dp[j1][j2],dp[j1-w1[i]][j2-w2[i]]+v[i]);cout<<dp[m1][m2];return 0;}```[AC记录](https://www.luogu.com.cn/record/237629208)86 行未改动27 行未改动28293031323334353674 行未改动11111211311411511611711811986 行未改动27 行未改动for(int j=m;j>=w[i];j--)dp[j]=max(dp[j],dp[j-w[i]]+v[i]);cout<<dp[m];return 0;}```[AC记录](https://www.luogu.com.cn/record/237045123)## 二、完全背包:[P1616 疯狂的采药](https://www.luogu.com.cn/problem/P1616)74 行未改动for(int i=1;i<=n;i++)for(int j1=m1;j1>=w1[i];j1--)for(int j2=m2;j2>=w2[i];j2--)dp[j1][j2]=max(dp[j1][j2],dp[j1-w1[i]][j2-w2[i]]+v[i]);cout<<dp[m1][m2];return 0;}```[AC记录](https://www.luogu.com.cn/record/237629208)86 行未改动