Bone Collector

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

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
 
Author
Teddy
 
Source
 

AC code:

#include <iostream>
using namespace std;
int main()
{
int t,n,v,i,j;
int weight[1005],value[1005],record[1005];
cin>>t;
while(t--)
{
memset(record,0,sizeof(record));
cin>>n>>v;
for(i=0; i<n; i++)
cin>>value[i];
for(i=0; i<n; i++)
cin>>weight[i];
for(i=0; i<n; i++)
{
for(j=v;j>=weight[i]; j--)
{
if(record[j-weight[i]]+value[i]>record[j])
record[j] = record[j-weight[i]]+value[i];
}
}
cout<<record[v]<<endl;
} return 0;
}

  

0-1背包问题(经典)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背包) 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 ...

  3. HDU2602 Bone Collector 【01背包】

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

  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. 【模板--完全背包】HDU--2602 Bone Collector

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

  6. Hdu2602 Bone Collector (01背包)

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

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

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

  8. hdu2602 Bone Collector (01背包)

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

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

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

随机推荐

  1. Linux中用户与用户组管理

    1.基础知识 Linux作为一种多用户的操作系统(服务器系统),允许多个用户同时登陆到系统上,并响应每个用户的请求. 任何需要使用操作系统的用户,都需要一个系统账号,账号分为:管理员账号与普通用户账号 ...

  2. 【HTML】placeholder中换行

    表示回车 表示换行 案例 <textarea rows="10" placeholder="测试换行 新的一行"></textarea>

  3. win8电脑字体出现方格的解决方法

    一般电脑出现乱码有几种可能,最常见的可能就是电脑字体的丢失,其次就是电脑字体被病毒所损坏,因此,首先我们要做的就是下载字体并进行安装. 下载 simsun.tcc点击安装,如果电脑字体依然是这种情况( ...

  4. POJ:3040-Allowance(贪心好题)

    Allowance Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4903 Accepted: 1943 Description ...

  5. STM32遇到的问题

    1.GPIO输出实验的时候,原来的库和现成的源代码有出入?导致实验现象不同,delay_ms,主要集中在这个函数上面 2.按键输入的时候,LED和KEY 初始化全部放在主函数,有按下按键以后,灯闪烁不 ...

  6. 4,Flask 中的 request

    每个框架中都有处理请求的机制(request),但是每个框架的处理方式和机制是不同的 为了了解Flask的request中都有什么东西,首先我们要写一个前后端的交互 基于HTML + Flask 写一 ...

  7. 如何将多个Eclipse项目导入IntelliJ IDEA

    技术交流群:233513714 IntelliJ IDEA 与Eclipse在新建项目上的叫法略有不同,区别见下图. 当我们使用idea后再次使用eclipse时就会有很多不适,下面介绍一个多项目的导 ...

  8. luogu2221 [HAOI2012]高速公路

    和sdoi的相关分析很像qwq,推柿子然后线段树搞搞 #include <iostream> #include <cstdio> using namespace std; ty ...

  9. 找出Xcode没有使用的图片

    #! /bin/sh PROJ=`find . -name '*.xib' -o -name '*.[mh]'` for png in ` find . -name '*.png'` do name ...

  10. 【Validation】林轩田机器学习基石

    这一节主要讲如何通过数据来合理的验证模型好不好. 首先,否定了Ein来选模型和Etest来选模型. (1)模型越复杂,Ein肯定越好:但是Eout就不一定了(见上一节的overfitting等) (2 ...