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 ? 

InputThe 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.OutputOne integer per line representing the maximum of the total value (this number will be less than 2 31).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;
int main()
{
int dp[],n,v,nv[],nm[],t;
while(cin>>t)
{
while(t--)
{
memset(dp,,sizeof(dp)); /*初始化*/
scanf("%d %d",&n,&v); /*读取骨头数量和背包重量*/
for(int i = ; i < n; i++) /*每一个骨头的价值*/
scanf("%d",&nv[i]);
for(int i = ; i < n; i++) /*每个骨头的重量*/
scanf("%d",&nm[i]); for(int i = ; i < n; i++)
for(int j = v; j >= nm[i];j--) /*dp算法*/
dp[j] = max(dp[j],dp[j-nm[i]]+nv[i]);
cout<<dp[v]<<endl;
}
} return ;
}

参考博客: 

ACM Bone Collector的更多相关文章

  1. hdu 2602 Bone Collector(01背包)模板

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...

  2. Bone Collector(01背包)

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/N 题目: Description Many year ...

  3. HDU 3639 Bone Collector II(01背包第K优解)

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

  4. Bone Collector II

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

  5. HDU 2602 Bone Collector (简单01背包)

    Bone Collector http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , i ...

  6. hdu 2602 Bone Collector 背包入门题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 题目分析:0-1背包  注意dp数组的清空, 二维转化为一维后的公式变化 /*Bone Coll ...

  7. hdu 2639 Bone Collector II

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

  8. HDU 2602 Bone Collector

    http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Others) ...

  9. Bone Collector II(HDU 2639 DP)

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

随机推荐

  1. mysql 千万级数据查询效率实践,分析 mysql查询优化实践--本文只做了一部分,仅供参考

    数据量, 1300万的表加上112万的表 注意: 本文只做了部分优化,并不全面,仅供参考, 欢迎指点.   请移步tim查看,因为写的时候在tim写的,粘贴过来截图有问题,就直接上链接了. https ...

  2. HTML笔记04---计时事件

    JavaScript运动01 计时事件 1.语法:var t=setTimeout("javascript语句",毫秒); setTimeout() 方法会返回某个值.在上面的语句 ...

  3. ionic轮播图

    根据自带的滑动图,只需要添加加红字体 <ion-view view-title="活动详情" class="align-title-center"> ...

  4. [LeetCode] Repeated String Match 重复字符串匹配

    Given two strings A and B, find the minimum number of times A has to be repeated such that B is a su ...

  5. AXIOS源代码重点难点分析

    摘要 vue使用axios进行http通讯,类似jquery/ajax的作用,类似angular http的作用,axios功能强大,使用方便,是一个优秀的http软件,本文旨在分享axios源代码重 ...

  6. 【实验吧】CTF_Web_登录一下好吗?

    实验吧CTF---Web篇 1. 打开登录地址(http://ctf5.shiyanbar.com/web/wonderkun/web/index.html),发现为一个登录界面,第一想到的是查看源代 ...

  7. 二哥的xss游戏

    断断续续做完了,收获挺多的. 地址:http://xsst.sinaapp.com/xss/ 二哥的xss游戏 第一题http://xsst.sinaapp.com/xss/ext/1.php?umo ...

  8. Office 365 应用开发的 .NET Core 模板库

    概述 前不久我写过一篇文章拥抱开源,Office 365开发迎来新时代,给大家介绍了Office 365开发的典型场景是如何支持开源平台的:Office 365通过Microsoft Graph,以R ...

  9. [NOIp 2011]Mayan游戏

    Description Mayan puzzle是最近流行起来的一个游戏.游戏界面是一个 7 行5 列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即方块必须放在最下面一行,或者放在其他方块之上.游戏 ...

  10. [Codeforces 863A]Quasi-palindrome

    Description Let quasi-palindromic number be such number that adding some leading zeros (possible non ...