描述:

  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. ultravnc

    virsh attach-disk

  2. UberX及以上级别车奖励政策(优步北京第四组)

    优步北京第四组: 定义为2015年7月20日至今激活的司机(以优步后台数据显示为准) 滴滴快车单单2.5倍,注册地址:http://www.udache.com/如何注册Uber司机(全国版最新最详细 ...

  3. #include <map>

    //tuple多元数组,必须是静态数组,类似结构体 //配合array,vector使用 //std::tuple<数组元素类型>数组变量名(数组元素变量名); #include < ...

  4. transition与visibility与display

    http://www.zhangxinxu.com/wordpress/2013/05/transition-visibility-show-hide/ 术语解释是: visibility: 离散步骤 ...

  5. var 与function的权重浅析

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Tomcat配置一个ip绑定多个域名

    在网上找了半天也没找到相关的资料,都说的太含糊. 本人对tomcat下配置 一ip对多域名的方法具体例如以下,按以下配置一定能成功,经过測试了. <Host name="localho ...

  7. 网页平面设计 CSS

    1.在html中引入css的方法 1.行内式 行内式即在标记的style属性中设定CSS样式,这种方式本质上没有体现出CSS的优势,因此不推荐使用. 例如:<h1 style="属性名 ...

  8. Java通过JDBC链接数据库,数据库中wen

    连接数据库设置编码 jdbc:mysql://地址:3306/数据库名?characterEncoding=utf8

  9. headfirst之装饰模式

    class A A.hello class B extends A B.hello = A.hello+B 装饰模式:子类对父类想要包装的方法进行重写,使之成为加强版

  10. C - 字符识别?

    C - 字符识别? Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Sta ...