We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No response
对于这样一个多重背包:买 N 件 i 物品,可以得到 A[i]*N+B[i] 的价值。
可以发现,第一次买可以得到 A[i]+B[i] 的价值。再次买可以得到 A[i] 的价值。
由此可以拆分成01背包和完全背包求解
for(int i=1; i<=n; i++){ for(int j=v; j>=w[i]; j--) dp[j]=max(dp[j],dp[j-w[i]]+a[i]+b[i]); for(int j=w[i]; j<=v; j++) dp[j]=max(dp[j],dp[j-w[i]]+a[i]); }
https://acm.hdu.edu.cn/showproblem.php?pid=5410
CRB and His Birthday
The text was updated successfully, but these errors were encountered:
感谢你对 OI Wiki 的关注!记得在 Issue 中表达清楚自己的意思哦~
Sorry, something went wrong.
No branches or pull requests
页面英文名
No response
我希望能添加的内容是
对于这样一个多重背包:买 N 件 i 物品,可以得到 A[i]*N+B[i] 的价值。
可以发现,第一次买可以得到 A[i]+B[i] 的价值。再次买可以得到 A[i] 的价值。
由此可以拆分成01背包和完全背包求解
for(int i=1; i<=n; i++){
for(int j=v; j>=w[i]; j--) dp[j]=max(dp[j],dp[j-w[i]]+a[i]+b[i]);
for(int j=w[i]; j<=v; j++) dp[j]=max(dp[j],dp[j-w[i]]+a[i]);
}
我了解到的相关参考资料有
https://acm.hdu.edu.cn/showproblem.php?pid=5410
CRB and His Birthday
The text was updated successfully, but these errors were encountered: