描述:

  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 ?

 

  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.

  One integer per line representing the maximum of the total value (this number will be less than 2 31).

代码:

  最基本的01背包。

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include <math.h>
using namespace std;
#define N 1005 int main(){
int T,n,v;
int worth[N],cost[N],dp[N];
scanf("%d",&T);
while( T-- ){
scanf("%d%d",&n,&v);
for( int i=;i<=n;i++ )
scanf("%d",&worth[i]);
for( int i=;i<=n;i++ )
scanf("%d",&cost[i]);
memset(dp,,sizeof(dp));
for( int i=;i<=n;i++ ){
for( int j=v;j>=cost[i];j-- ){
dp[j]=max(dp[j],dp[j-cost[i]]+worth[i]);
}
}
printf("%d\n",dp[v]);
}
system("pause");
return ;
}

HDU2602-Bone Collector的更多相关文章

  1. HDU2602 Bone Collector(01背包)

    HDU2602 Bone Collector 01背包模板题 #include<stdio.h> #include<math.h> #include<string.h&g ...

  2. HDU2602 Bone Collector 【01背包】

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

  3. 【模板--完全背包】HDU--2602 Bone Collector

    Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...

  4. hdu2602 Bone Collector 01背包

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

  5. Hdu2602 Bone Collector (01背包)

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  6. hdu2602 Bone Collector(01背包) 2016-05-24 15:37 57人阅读 评论(0) 收藏

    Bone Collector Problem Description Many years ago , in Teddy's hometown there was a man who was call ...

  7. 0-1背包问题(经典)HDU2602 Bone Collector

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

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

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

  9. hdu2602 Bone Collector (01背包)

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

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

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

随机推荐

  1. C++实现Http Post请求

    参考资料: http://apps.hi.baidu.com/share/detail/39003388 http://blog.csdn.net/yc0188/article/details/474 ...

  2. Android的UI两大基石

        说到Android的UI就不得不从一切的开始View开始说.     让我们从Android Developer上的View的Overview和UI Overview来开始吧.     Cla ...

  3. ToDoList-学习中看到的知识盲点

    1. java中的volatile关键字的作用 2. java类加载器 3. Android源码编译 4. MediaPlayer的用法 5. Html5和web app

  4. spring schema自定义

    今天看了一下分布式服务框架的那本书,于是里面提到了spring schema的自定义,于是去简单的了解了一下 参考资源:spring schema扩展: http://www.yihaomen.com ...

  5. 用C++写一个简单的服务器和客户端

    我们将创建一个服务器节点add_two_ints_server,它将会收到两个整数,并且返回它们的和.切换目录到之前建立的beginner_tutorials包下: cd ~/catkin_ws/sr ...

  6. js调用ASP.NET打印代码

    第一步:添加下面的js <script type="text/javascript">           function printsetup() {        ...

  7. Android 图片处理效果集

    总共可以处理出大约100种图片效果,常见的和不常见的滤镜效果可以处理出来,可以说涵盖了市面上所有特效相机可以处理出来的效果.项目所有代码都是纯java代码实现,没有封装成jar包.截图是挑选了几张有代 ...

  8. junit的安装和使用

    一.junit的安装: junit-4.11.jar: http://www.java2s.com/Code/Jar/j/Downloadjunit411jar.htm hamcrest-core.j ...

  9. 阿里云服务器linux(centos)常用命令

    系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS ...

  10. 在FL2440上使用kei MDK 调试程序(J-link)

    <一>新建一个工程 单击Project ->New µVision Project...菜单项 <二>选择CPU 这里我们选择三星的2440A 点击OK后会提示你是否添加 ...