博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu——2602Bone Collector(第一类背包问题)
阅读量:4047 次
发布时间:2019-05-25

本文共 1932 字,大约阅读时间需要 6 分钟。

Bone Collector

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 46744    Accepted Submission(s): 19463
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 2
31).
 
Sample Input
15 101 2 3 4 55 4 3 2 1
 
Sample Output
14
 
Author
Teddy
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:            

 

第一类背包  for(i=1;i<=n;i++)

for(j=V;j>v[i];j--)

d[j]=max(d[j],d[j-v[i]]+jg[i])

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;struct bb{ long long v; long long jz;}a[1005];long long max(long long n,long long m){ if(n>=m)return n; else return m;}int main(){ long long n,m,vv,sum[1005]; cin>>n; while(n--) { cin>>m>>vv; memset(sum, 0, sizeof(sum)); for(int i=0;i
>a[i].jz; } for(int i=0;i
>a[i].v; } for(int i=0;i
=a[i].v;j--) { sum[j]=max(sum[j],sum[j-a[i].v]+a[i].jz); } } cout<
<

转载地址:http://btfci.baihongyu.com/

你可能感兴趣的文章
自定义 select 下拉框 多选插件
查看>>
js获取url链接携带的参数值
查看>>
gdb 调试core dump
查看>>
gdb debug tips
查看>>
arm linux 生成火焰图
查看>>
linux和windows内存布局验证
查看>>
linux insmod error -1 required key invalid
查看>>
linux kconfig配置
查看>>
linux不同模块completion通信
查看>>
linux printf获得时间戳
查看>>
C语言位扩展
查看>>
linux irqdebug
查看>>
git 常用命令
查看>>
linux位操作API
查看>>
uboot.lds文件分析
查看>>
uboot start.s文件分析
查看>>
没有路由器的情况下,开发板,虚拟机Ubuntu,win10主机,三者也可以ping通
查看>>
本地服务方式搭建etcd集群
查看>>
安装k8s Master高可用集群
查看>>
忽略图片透明区域的事件(Flex)
查看>>