Bone Collector

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 52296    Accepted Submission(s): 22040

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
 
裸的01背包
 //2016.9.6
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int N = ;
int dp[N], c[N], w[N]; int main()
{
int T, n, v;
cin>>T;
while(T--)
{
scanf("%d%d", &n, &v);
memset(dp, , sizeof(dp));
for(int i = ; i < n; i++)
scanf("%d", &w[i]);
for(int i = ; i < n; i++)
scanf("%d", &c[i]);
for(int i = ; i < n; i++)
for(int j = v; j >= c[i]; j--)
dp[j] = max(dp[j], dp[j-c[i]]+w[i]);
printf("%d\n", dp[v]);
} return ;
}

HDU2602(背包)的更多相关文章

  1. hdu-2602&&POJ-3624---01背包裸题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 https://vjudge.net/problem/POJ-3624 都是01背包的裸题 这 ...

  2. HDU2602 Bone Collector(01背包)

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

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

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

  4. HDU2602 Bone Collector 【01背包】

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

  5. hdu2602 Bone Collector (01背包)

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

  6. hdu2602 Bone Collector 01背包

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

  7. hdu2602 DP (01背包)

    题意:有一个容量 volume 的背包,有一个个给定体积和价值的骨头,问最多能装价值多少. 经典的 01 背包问题不谈,再不会我就要面壁了. 终于有一道题可以说水过了 ……心好累 #include&l ...

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

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

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

随机推荐

  1. highcharts 去掉打印和链接

    1)去掉或更改图片右下角的链接 在highcharts.js文件中搜索credits字符串,找到如下的字符串, enabled:设置是否显示链接 text:设置链接显示的名称 href:设置链接的ur ...

  2. LB 高可扩展性集群(负载均衡集群)

    一.什么是负载均衡 首先我们先介绍一下什么是负载均衡: 负载平衡(Load balancing)是一种计算机网络技术,用来在多个计算机(计算机集群).网络连接.CPU.磁盘驱动器或其他资源中分配负载, ...

  3. php的几个内置的函数

    // 取得所有的后缀为PHP的文件 $files = glob(‘*.php’); print_r($files); j

  4. Javascript Fromdata 与jQuery 实现Ajax文件上传

    <!DOCTYPE html> <html> <head> <title>ajax</title> <script type=&quo ...

  5. 【转】C++中this指针的用法详解

    1.this指针的用处 一个对象的this指针并不是对象本身的一部分,不会影响sizeof(对象)的结果.this作用域是在类内部,当在类的非静态成员函数中访问类的非静态成员的时候,编译器会自动将对象 ...

  6. iOS-模糊查询

    http://blog.csdn.net/qq_33701006/article/details/51836914 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   前言 ...

  7. IOS第三方数据库--FMDB 分类: ios技术 2015-03-01 09:38 57人阅读 评论(0) 收藏

    iOS中原生的SQLite API在使用上相当不友好,在使用时,非常不便.于是,就出现了一系列将SQLite API进行封装的库,例如FMDB.PlausibleDatabase.sqlitepers ...

  8. php 利用socket上传文件

    php 利用socket上传文件 张映 发表于 2010-06-02 分类目录: php 一,利用fsockopen来上传文件 以前我写过一篇关于socket通信原理的博文http://blog.51 ...

  9. 安卓弹出对话框——AlertDialog(二)

    在Android中,启动一个对话框有三种方式: 1.定义一个新的activity,并将其主题设置为对话框风格 2.使用AlertDialog类,并且显示它 3.使用 Android的Dialog类的子 ...

  10. Ubuntu安装飞鸽传输

    飞鸽传书下载地址 http://www.ipmsg.org.cn/ipmsg/download.html 下载以后解压压缩包,会有一个可执行文件,executable文件. ./Qipmsg 如果没报 ...