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 231).
 
Sample Input
1
5 10
1 2 3 4 5
5 4 3 2 1
 
Sample Output
14
 
 #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背包)的更多相关文章

  1. hdu2602 Bone Collector 01背包

    Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like ...

  2. [原]hdu2602 Bone Collector (01背包)

    本文出自:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //=================================== ...

  3. hdu2602 Bone Collector (01背包)

    本文来源于:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //================================== ...

  4. 解题报告:hdu2602 Bone collector 01背包模板

    2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:ppr ...

  5. HDU-2602 Bone Collector——01背包

    首先输入一个数字代表有n个样例 接下来的三行 第一行输入n  和  v,代表n块骨头,背包体积容量为v. 第二行输入n块骨头的价值 第三行输入n块骨头的体积 问可获得最大的价值为多少 核心:关键在于d ...

  6. Bone Collector(01背包+记忆化搜索)

    Bone Collector Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  7. HDU 2602 Bone Collector(01背包裸题)

    Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  8. HDU 2602 - Bone Collector - [01背包模板题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Many years ago , in Teddy’s hometown there was a ...

  9. HDU 2602 Bone Collector --01背包

    这种01背包的裸题,本来是不想写解题报告的.但是鉴于还没写过背包的解题报告.于是来一发. 这个真的是裸的01背包. 代码: #include <iostream> #include < ...

  10. ACM HDU Bone Collector 01背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 这是做的第一道01背包的题目.题目的大意是有n个物品,体积为v的背包.不断的放入物品,当然物品有 ...

随机推荐

  1. 简单的Verilog测试模板结构

    这里记录一下曾经用到的简单的测试模板,如下所示: //timescale `timescale 1ns/1ns module tb_module(); //the Internal motivatio ...

  2. sublime 安装ctags跳转以及跳转快捷键

    在source insight中有一个很好用的功能,就是函数的跟踪跳转,在阅读别人的代码的时候轻松的浏览原函数.我们知道,在使用vim的时候有个插件叫ctags,同理,在sublime text中也能 ...

  3. An overview of gradient descent optimization algorithms

    原文地址:An overview of gradient descent optimization algorithms An overview of gradient descent optimiz ...

  4. 使用 ASP.NET SignalR实现实时通讯

    ASP.NET SignalR 是为 ASP.NET 开发人员提供的一个库,可以简化开发人员将实时 Web 功能添加到应用程序的过程.实时 Web 功能是指这样一种功能:当所连接的客户端变得可用时服务 ...

  5. 剑指offer——python【第37题】数字在排序数组中出现的次数

    题目描述 统计一个数字在排序数组中出现的次数 思路 最贱的方法依旧是count计数.. 当然,,看到有序数组就应该想到二分法,找到重复数字左边和右边的数字,然后两个相减就可以了 解答 方法1 coun ...

  6. Python学习之旅(十八)

    Python基础知识(17):面向对象编程(Ⅱ) 获取对象信息 在不知道对象信息的情况下,我们想要去获取对象信息,可以使用以下方法 1.type (1)判断对象类型 >>> type ...

  7. Herriott池的设计

    0.矩阵法计算光路 1.谐振腔和透镜组的等效,计算x和x’ 2.近轴光路的近似计算和矩阵法. 3.相邻光线的角度 4.为啥分模式 5.椭圆模式 6.要考虑的其他问题,相邻光斑的干涉

  8. Linux 命令 which whereis locate find

    which: 查询某指令的完整路径 $ which [-a] command -a: 将所有在PATH目录中可以找到的指令均列出. 注意:只搜索PATH下的路径. whereis: 只搜索几个特定目录 ...

  9. mybatis mapper-locations作用

    application上配置了@MapperScan(扫面mapper类的路径)和pom.xml中放行了mapper.xml后,配置mapper-locations没有意义 查找后得知,如果mappe ...

  10. css学习_css清除浮动

    若元素没有设置宽高,那元素实际宽高是被内容撑起来, 若元素自己有设置宽高,那实际面积于自己的盒子模型有关 1.清除浮动的本质 清除浮动主要是为了解决父级元素因为子级浮动而引起的内部高度为0的问题. ( ...