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的背包.不断的放入物品,当然物品有 ...
随机推荐
- Tensorflow r1.8安装C++接口(兼容OpenCV3)
与之前一样,直接走medium的传送门:https://medium.com/@fanzongshaoxing/use-tensorflow-c-api-with-opencv3-bacb83ca56 ...
- 深入浅出MySQL++数据库开发、优化与管理维护+第2版+唐汉明 -- 存储引擎 - 数据类型 - 字符集和校验规则 -
create schema deepInMySql;use deepInMySql; -- 查看当前默认存储引擎show variables like '%table_type%'; -- 查看当前数 ...
- iOS - 国内注册境外 Apple id 账号
注册前准备工作 需要手头MAC一台 AppStore下载VPN Plus FQ到美国(ipip.net 查看当前ip 是否是在境外 当前ip 在境外才可以哦) 动手搞起来 https://applei ...
- 【问题】Can't load AMD 64-bit .dll on a IA 32-bit platform
文件下载地址:http://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.2.14/binaries/ 按自己的提示找到32位或者 ...
- RecyclerView实现分组展示信息
extends:http://blog.csdn.net/wzlyd1/article/details/52292548 前言 一直在鸿洋大神的安卓群里水群,渐渐的loader和安卓弟等人都成长了起来 ...
- nginx_ssl_tomcat配置
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" ...
- 浅析 Hinton 最近提出的 Capsule 计划
[原文] 浅析 Hinton 最近提出的 Capsule 计划 关于最新的 Hinton 的论文 Dynamic Routing Between Capsules,参见 https:// ...
- juqery 回车事件 回车操作 回车搜索
html <form class="search_wrap" method="post" action=""> <div ...
- MOT上海站 | 卓越研发之路:微服务之路
微服务架构在带来灵活性.扩展性.可用性等优点的同时,其复杂性也给架构师们带来了很大的挑战.当你面对这些挑战一筹莫展时,不妨来参加由msup和微软联合推出的MOT线下沙龙活动吧,我们将给您答疑解惑. M ...
- WebService,ESB笔记
一.WebService是什么? WebService,是RPC的一样实现方式. RPC(Remote Procedure Call Protocol)--远程过程调用协议,它是一种通过网络从远程计算 ...