hdu2602-01背包水题
来源:互联网 发布:用淘宝联盟卖家知道吗 编辑:程序博客网 时间:2024/06/05 11:36
和poj3624相似,只不过用骨头换宝藏。就直接上代码:
#include<cstdio>#include<cstring>#include<iostream>using namespace std;const int maxn=1050;const int Maxn=1050;int f[maxn];int c[Maxn],w[Maxn];int main(){ int T; scanf("%d",&T); while(T--){ int n,m; scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ scanf("%d",&w[i]); } for(int i=0;i<n;i++){ scanf("%d",&c[i]); } memset(f,0,sizeof(f)); for(int i=0;i<n;i++){ for(int v=m;v>=0&&v-c[i]>=0;v--) f[v]=max(f[v],f[v-c[i]]+w[i]); } int mx=0; for(int i=0;i<=m;i++) mx=max(mx,f[i]); printf("%d\n",mx); } return 0;}
0 0
- hdu2602-01背包水题
- hdu2602-Bone Collector(01背包模版题)
- HDU2602-Bone Collector-01背包(模板题)
- hdu2602(01背包模板题)
- hdu2602 Bone Collector 01背包教学题
- hdu2602!01背包问题
- hdu2602 dp 01背包
- 01背包 HDU2602
- hdu2602 01背包 题解
- 01背包-hdu2602
- hdu2602 01背包问题
- hdu2602 01背包
- hdu2602(01背包)
- HDU2602 01背包问题
- 01背包 HDU2602
- hdu2602-01背包
- HDU2602(01背包)
- HDU2602-01背包基础
- 写网页内容需要注意些什么?
- Python Books and resources list
- 什么叫反向链接?什么是死链接?什么是错误链接?
- 玩转java(1)— 泛型
- Tomcat集群Cluster实现原理剖析
- hdu2602-01背包水题
- 十年 好友 相遇
- 轻松掌握ISO8583报文协议 http://www.itpub.net/thread-419521-1-1.html
- windows游戏编程<八> 绘图基础
- ubuntu中配置完美Vim
- 关于开房的笑话 (转自 www.lenxiaohuadaquan.net )
- 算法 双堆维护中位数
- SDUTOJ 1197 约瑟夫问题——循环链表解法数学解法和循环队列
- 无法识别的属性“targetFramework”---解决之道