UVA 10130 - SuperSale(0-1背包问题)
来源:互联网 发布:淘宝卖电影资源被罚 编辑:程序博客网 时间:2024/06/05 18:57
#include <iostream>#include <cstdio>#include <cstring>#include <queue>#define M 1000+10using namespace std;int p[M],w[M],dp[M];int main(){ int T,n,m,c; cin>>T; while(T--) { cin>>n; for(int i=0; i<n; i++) cin>>p[i]>>w[i]; cin>>m; int sum=0; while(m--) { cin>>c; memset(dp,0,sizeof(dp)); for(int i=0; i<n; i++) for(int j=c; j>=0; j--) if(j>=w[i]) dp[j]=max(dp[j],dp[j-w[i]]+p[i]); sum+=dp[c]; } cout<<sum<<endl; } return 0;}
0 0
- UVA 10130 - SuperSale(0-1背包问题)
- Uva 10130-SuperSale(0-1背包)
- UVa 10130 SuperSale (0-1背包)
- UVA 10130 SuperSale 0-1背包
- UVA 10130 SuperSale(背包)
- UVA - 10130 SuperSale 01背包问题
- UVa 10130 - SuperSale 背包
- uva 10130 SuperSale(01背包)
- UVA - 10130 SuperSale (01背包)
- uva 10130 SuperSale (01背包)
- uva 10130 - SuperSale(01背包)
- Uva-10130 SuperSale 01背包
- UVa 10130 SuperSale(DP_01背包)
- SuperSale - UVa 10130 01背包
- 【UVA】10130-SuperSale(01背包)
- UVA 10130 SuperSale(01背包)
- UVa 10130 SuperSale 01背包问题 入门题
- uva 10130 - SuperSale(01背包简单变换)
- C++的函数重载
- Android直接强制退出
- CentOS6下docker的安装和使用
- VR相关网站
- 欢迎使用CSDN-markdown编辑器
- UVA 10130 - SuperSale(0-1背包问题)
- MFC中 给基于对话框的应用程序添加登陆界面
- 微信企业号之获取所有部门列表
- ob_flush和flush区别
- 内存碎片问题
- UVA 11137 - Ingenuous Cubrency(简单背包问题)
- glassfish4系统启动脚本
- 保存为字符串元素,然后打印字符串出错原因
- 解决dns没问题,能上qq不能上网的问题