hdu 2602 Bone Collector
来源:互联网 发布:软件开发需求任务 编辑:程序博客网 时间:2024/03/28 16:25
题目描述:
Bone Collector
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14889 Accepted Submission(s): 5911
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 ?
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.
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
15 101 2 3 4 55 4 3 2 1
Sample Output
14
Author
Teddy
Source
HDU 1st “Vegetable-Birds Cup” Programming Open Contest
Recommend
lcy
思路:
最原始的背包问题:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<set>#include<queue>#define inf 0xfffffff#define CLR(a,b) memset((a),(b),sizeof(a))using namespace std;int const nMax = 1100;int dp[nMax];int v[nMax],a[nMax];int n,V;int DP(){ CLR(dp,0); for(int k=0;k<n;k++){ for(int i=V;i>=0;i--)if(i>=a[k]){ dp[i]=max(dp[i],max(dp[i-1],dp[i-a[k]]+v[k])); } } return dp[V];}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&V); for(int i=0;i<n;i++)scanf("%d",&v[i]); for(int i=0;i<n;i++)scanf("%d",&a[i]); printf("%d\n",DP()); } return 0;}
- HDU 2602 Bone Collector
- hdu 2602 Bone Collector
- hdu 2602 Bone Collector
- hdu 2602 Bone Collector
- HDU 2602 - Bone Collector
- HDU 2602 Bone Collector
- hdu 2602 Bone Collector
- HDU 2602 Bone Collector
- hdu 2602 Bone Collector
- hdu 2602 Bone Collector
- Hdu 2602 - Bone Collector
- hdu 2602 Bone Collector
- hdu 2602 Bone Collector
- Hdu 2602 Bone Collector
- Hdu 2602 Bone Collector
- hdu 2602 Bone Collector
- hdu - 2602 - Bone Collector
- hdu 2602 Bone Collector
- 倔强是任性的伤害 我谁也不怪
- 数据的标准化
- activiti学习资料(job)
- 大端模式与小端模式
- SQL注射语句的经典总结
- hdu 2602 Bone Collector
- 繁华落幕,指尖的流沙散尽记忆的来路
- 文章检索及数据库破解方法
- VS程序部署和调试
- 突破自我,才会有进步
- Mysql 中文乱码 问题 完美 解决方案 详解!
- <zz>latex中图片和文字并列排放
- SWFUpload简单使用例子 Java版(JSP)
- 关于google技巧