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. Unity游戏推送技术

    https://www.cnblogs.com/wuzhang/p/wuzhang20150401.html https://www.cnblogs.com/yangwujun/p/5789969.h ...

  2. react项目使用bootstrap

    曾经对于react项目怎么使用bootstrap纠结了很久,网上也查了好多的资料,有的用react-bootstrap,只要npm install 以后,import就可以使用里面的css了.但是这个 ...

  3. 使用glusterfs 作为 kubernetes PersistentVolume PersistentVolumeClaim 持久化仓库,高可用Rabbitmq,高可用mysql,高可用redis

    glusterfs 怎么集群,网上一搜铺天盖地的 可利用这个特点做单节点高可用,因为K8S 哪怕节点宕机了 master 会在随意一台节点把挂掉的复活 当然我是在自己的环境下跑,经过网络的gluste ...

  4. 19. vue的原理

    vue:原理1 => Object.defineProperty 当你把一个普通的 JavaScript 对象传给 Vue 实例的 data 选项,Vue 将遍历此对象所有的属性,并使用 Obj ...

  5. vue里的渲染以及computed的好处

    如果vue里的某个methods函数执行,导致页面重新渲染,那么所有页面渲染相关的methods函数会重新执行以及时的渲染页面 但是大量函数的重新没有必要的执行会导致性能的下降, 此时如果把没有必要再 ...

  6. HttpClient学习记录-系列2(源码学习)

    如何阅读第三方工具源码? 存在多个入口,而且整个类图存在很多孤岛,自上而下的分析策略貌似不行,还是从use case入手,针对单个面分析.难点是如何做范围界定?不至于陷入黑洞 HttpGet   -- ...

  7. DWZ富客户端框架使用手册【申明:来源于网络】

    DWZ富客户端框架使用手册[申明:来源于网络] ---- 地址:http://www.docin.com/p-288065388.html&s=C1218A403B04136160905E8E ...

  8. webstorm 介绍

    最新版2017 破解 注册时,在打开的License Activation窗口中选择“License server”,在输入框输入下面的网址: http://idea.iteblog.com/key. ...

  9. Ubuntu系统启动后停在(initramfs)

    问题 今天我在启动虚拟机过程 遇到莫名其妙的问题,启动不了.如下图.提示某个文件系统错误了.例如我的就是 /dev/mapper/vagrant--vg-root . 上面问题 可把我急坏了,以为虚拟 ...

  10. MGF 637: Financial Modeling

    MGF 637: Financial ModelingSpring 2019Extra Credit AssignmentInstructions: This is an extra credit o ...