Skip to content
New issue

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

Add 权值较为复杂的多重背包 #5379

Open
cbs001 opened this issue Jan 27, 2024 · 1 comment
Open

Add 权值较为复杂的多重背包 #5379

cbs001 opened this issue Jan 27, 2024 · 1 comment
Labels
Content Request / 内容请求 New feature or request

Comments

@cbs001
Copy link

cbs001 commented Jan 27, 2024

页面英文名

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

@cbs001 cbs001 added the Content Request / 内容请求 New feature or request label Jan 27, 2024
Copy link

welcome bot commented Jan 27, 2024

感谢你对 OI Wiki 的关注!记得在 Issue 中表达清楚自己的意思哦~

@Tiphereth-A Tiphereth-A changed the title 权值较为复杂的多重背包 Add 权值较为复杂的多重背包 Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content Request / 内容请求 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant