Bone Collector(HDU-2602)
Problem Description
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …
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 ?Input
The first line contain a integer T , the number of cases.
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.
Output
One integer per line representing the maximum of the total value (this number will be less than 2^31).
Sample Input
1
5 10
1 2 3 4 5
5 4 3 2 1Sample Output
14
思路:0-1背包裸题
Source Program
#include<iostream>
#include<cstring>
using namespace std;
int dp[1001];
int main()
{int t;int n,v;int c[1001],w[1001];int i,j;cin>>t;while(t--){memset(dp,0,sizeof(dp));cin>>n>>v;for(i=1;i<=n;i++)cin>>w[i];for(i=1;i<=n;i++)cin>>c[i];for(i=1;i<=n;i++)for(j=v;j>=c[i];j--)dp[j]=max(dp[j],dp[j-c[i]]+w[i]);cout<<dp[v]<<endl;}return 0;
}
Bone Collector(HDU-2602)相关推荐
- hdu 2602 Bone Collector(01背包)模板
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...
- HD 2602 Bone Collector (0-1背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , in Teddy's ...
- hdu 2602 Bone Collector(01背包)
题意:给出包裹的大小v,然后给出n块骨头的价值value和体积volume,求出一路下来包裹可以携带骨头最大价值 思路:01背包 1.二维数组(不常用 #include<iostream> ...
- B - Bone Collector (01背包)
题目: 涂奥最近迷上了吃鸡,房间有n个配件,每个配件有c(c<=1e3)的重量和v(v<=1e3)的价值,哇,涂奥捡了一个2级包,容量为s,所以涂奥最多当多肥的快递员呢? Input 输入 ...
- 有源汇有上下界最大流/最小流 配题(HDU 3157)
因为是有源汇所以设源点为 s,汇点为 t. 有源汇有上下界最大流: 连接一条 t 指向 s 的边,容量为 INF. 通过上述步骤,现在图变成了无源汇网络. 引入超级源点 S,超级汇点 T. 连接一条 ...
- Bone Collector(01背包问题-两种写法)
Many years ago , in Teddy's hometown there was a man who was called "Bone Collector". This ...
- 背包——01背包Bone Collector(hdu2602)
首先说明一下01背包 有一个容量为V的背包,另外有N个物品,每个物品Ni都有其对应的体积Vi和价值Pi 求如何取舍装进背包中使得背包里的总价值P达到最大值 题目看似很像贪心问题,把我们不妨先以贪心的思 ...
- Bone Collector(骨头收集者)c++(01背包问题)
题目来源:杭州电子科技大学 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 最大表示法--环形字符串最大字典序(HDU 5442)
http://acm.hdu.edu.cn/showproblem.php?pid=5442 问题概述:n个字符围成一个环,请从这个环中找出字典序最大的长度为n的字符串,输出它的起始点和方向(0顺1 ...
最新文章
- 全民自动驾驶5年内真的会来吗?这是Lyft的自动驾驶2.0
- java actionsupport_struts2中的Action接口和Actionsupport接口各有什么作用
- 前端技术-调试工具(上)
- 选择排序和冒泡排序以及折半查找
- python中a and b什么意思_Python中的a+=b和a=a+b之间的区别是什么?
- Table_Vue table 表格中显示内容过长显示省略号_并且显示提示---SpringCloud Alibaba_若依微服务框架改造_前端ElementUI---工作笔记010
- 产品固件(系统)升级——curl/wget
- 8086、80286、80386
- windows系统镜像修复计算机,为你详解win7系统还原及映像修复功能
- 计算机日历教案,《认识日历》的教案
- word回车后间距太大_word编辑按回车换行上下间距好大怎么回事
- GBU808-ASEMI品质家电用桥堆制柜整流桥
- 保护模式(四)长调用与短调用 调用门
- Mac 开发 打开系统偏好设置
- android单手模式,OPPO手机单手模式怎么操作?
- macOS 运行 iOS 应用体验:你甚至能在电脑上刷微信朋友圈
- php 动态网格,ZBrush中的动态网格该怎么进行运用
- 转载:详解Quartus导出网表文件:.qxp和.vqm
- 20210316_23期_心跳检测_Task01
- 6.3 快速更改图表的数据源 [原创Excel教程]