博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bone Collector 01背包问题
阅读量:4358 次
发布时间:2019-06-07

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

题目描述

 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 231).
 

示例输入

15 101 2 3 4 55 4 3 2 1

示例输出

14 第一次做背包问题,研究的别人的代码
这张图片就可说明问题
1 #include
2 #include
3 int main() 4 { 5 int t,n,v,f[1001],vol[1001],val[1001],sum; 6 scanf("%d",&t); 7 for(int i=1;i<=t;i++) 8 { 9 scanf("%d %d",&n,&v);10 for(int i=0;i
=vol[i];j--)18 {19 sum=f[j-vol[i]]+val[i];20 if(f[j]

 

转载于:https://www.cnblogs.com/wlc297984368/p/3263976.html

你可能感兴趣的文章
linux下oracle调试小知识
查看>>
alert弹出窗口,点击确认后关闭页面
查看>>
oracle问题之数据库恢复(三)
查看>>
单点登陆(SSO)
查看>>
HR,也确实“尽职尽责”
查看>>
MaxComputer 使用客户端配置
查看>>
20190823 顺其自然
查看>>
阅读《余生有你,人间值得》有感
查看>>
每日英语
查看>>
SpringCloud+feign 基于Springboot2.0 负载均衡
查看>>
【BZOJ5094】硬盘检测 概率
查看>>
mac上n次安装与卸载mysql
查看>>
Python之单元测试——HTMLTestRunner
查看>>
WebNotes(PHP、css、JavaScript等)
查看>>
C++:文件的输入和输出
查看>>
Http协议、Tomcat、servlet
查看>>
Spring Boot (11) mybatis 关联映射
查看>>
macOS 下安装tomcat
查看>>
字符串格式化复习笔记
查看>>
jquery之ajax
查看>>