Hdu2602 Bone Collector (01背包)
The bone collector had a big bag with a volume of V ,and along his trip of collecting there are a lot of bones , obviously , different bone has different value and different volume, now given the each bone’s value along his trip , can you calculate out the maximum of the total value the bone collector can get ?
Followed by T cases , each case three lines , the first line contain two integer N , V, (N <= 1000 , V <= 1000 )representing the number of bones and the volume of his bag. And the second line contain N integers representing the value of each bone. The third line contain N integers representing the volume of each bone.
5 10
1 2 3 4 5
5 4 3 2 1
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t,n,W;
ll v[];
int w[];
ll dp[][];
int main()
{
cin>>t;
while(t--){
cin>>n>>W;
for(int i=;i<n;i++) cin>>v[i];
for(int i=;i<n;i++) cin>>w[i];
for(int i=;i<n;i++){
for(int j=;j<=W;j++){
if(j<w[i]) dp[i+][j]=dp[i][j];
else dp[i+][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
}
}
cout<<dp[n][W]<<endl;
}
return ;
}
Hdu2602 Bone Collector (01背包)的更多相关文章
- hdu2602 Bone Collector 01背包
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like ...
- [原]hdu2602 Bone Collector (01背包)
本文出自:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //=================================== ...
- hdu2602 Bone Collector (01背包)
本文来源于:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //================================== ...
- 解题报告:hdu2602 Bone collector 01背包模板
2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:ppr ...
- HDU-2602 Bone Collector——01背包
首先输入一个数字代表有n个样例 接下来的三行 第一行输入n 和 v,代表n块骨头,背包体积容量为v. 第二行输入n块骨头的价值 第三行输入n块骨头的体积 问可获得最大的价值为多少 核心:关键在于d ...
- Bone Collector(01背包+记忆化搜索)
Bone Collector Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- HDU 2602 Bone Collector(01背包裸题)
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 2602 - Bone Collector - [01背包模板题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Many years ago , in Teddy’s hometown there was a ...
- HDU 2602 Bone Collector --01背包
这种01背包的裸题,本来是不想写解题报告的.但是鉴于还没写过背包的解题报告.于是来一发. 这个真的是裸的01背包. 代码: #include <iostream> #include < ...
- ACM HDU Bone Collector 01背包
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 这是做的第一道01背包的题目.题目的大意是有n个物品,体积为v的背包.不断的放入物品,当然物品有 ...
随机推荐
- composer lavarel 安装
一:packagist库:https://packagist.org/packages/laravel/laravel 二:composer安装 // 安装到laravel文件夹 composer c ...
- 外部访问docker容器(docker run -p/-P 指令)
容器中可以运行一些网络应用,要让外部也可以访问这些应用,可以通过 -P(大写) 或 -p (小写) 参数来指定端口映射. (1)当使用 -P 标记时,Docker 会随机映射一个 49000~4990 ...
- Redis 数据结构的实现
Redis 数据结构的实现 先看个对照关系: Redis数据结构 实现一 实现二 string 整数(如果value能够表示为整数) 字符串 hash 压缩列表(只包含少量键值对, 并且每个键值对的键 ...
- 【QT】QT更改构建目录
菜单“工具”-“选项”. Qt Creator怎样更改默认构建目录_百度经验 https://jingyan.baidu.com/article/6181c3e0b9d170152ef153af.ht ...
- linux中,当执行rpm -e删除一个软件包时,都做了些什么事
问题描述: 今天在通过rpm进行删除软件包时,出现了问题,就引发了我对于rpm包执行删除动作时的一些行为做了思考,之前找了很多的文章,后来想如果有debug日志信息,那么不就都清楚了吗 通过打印rpm ...
- CentOS 6.8 防火墙配置
系统: CentOS release 6.8 (Final) iptables v1.4.7 执行命令: #清除所有规则 iptables -F #开放redis端口 iptables -A INPU ...
- Qt编写自定义控件9-导航按钮控件
前言 导航按钮控件,主要用于各种漂亮精美的导航条,我们经常在web中看到导航条都非常精美,都是html+css+js实现的,还自带动画过度效果,Qt提供的qss其实也是无敌的,支持基本上所有的CSS2 ...
- linux的基本操作(磁盘管理)
磁盘管理 [查看磁盘或者目录的容量 df 和 du] df 查看已挂载磁盘的总容量.使用容量.剩余容量等,可以不加任何参数,默认是按k为单位显示的 df常用参数有 –i -h -k –m等 -i 使用 ...
- create database link
如果本地的tnsnames.ora中未建立数据库连接,那么就是用1,否则就是用2 1:create database link geelyin96 connect to geelyin identif ...
- 微信小程序时间戳的转换及调用
13位 的时间戳,如下图: 效果图: 1.(utils.js里面的代码): function formatTime(timestamp, format) { const formateArr = [' ...