HDU2602 DP + 裸 + 01背包
来源:互联网 发布:福州靠谱网络 招聘 编辑:程序博客网 时间:2024/06/11 04:14
1)
#include <iostream>#include <string.h>using namespace std;const int maxn=1010;int value[maxn];int volume[maxn];long long int dp[maxn];int main(){ int kase; cin>>kase; while(kase--){ memset(dp,0,sizeof(dp)); int n,v; cin>>n>>v; for(int i=1;i<=n;i++){ cin>>value[i]; } for(int i=1;i<=n;i++){ cin>>volume[i]; } for(int i=1;i<=n;i++){ for(int j=v;j>=volume[i];j--){ dp[j]=max(dp[j],dp[j-volume[i]]+value[i]); } } cout<<dp[v]<<endl; }}
2)
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
0 0
- HDU2602 DP + 裸 + 01背包
- hdu2602 dp 01背包
- HDU2602 Bone Collector 01背包DP 模板题
- Bone Collector hdu2602(经典dp)01背包
- hdu2602!01背包问题
- 01背包 HDU2602
- hdu2602 01背包 题解
- 01背包-hdu2602
- hdu2602 01背包问题
- hdu2602 01背包
- hdu2602(01背包)
- HDU2602 01背包问题
- 01背包 HDU2602
- hdu2602-01背包
- HDU2602(01背包)
- HDU2602-01背包基础
- hdu2602 简单01背包
- 01背包 hdu2546 hdu2602
- strchr strrchr strcmp的实现
- 2-2 Verilog 7 段译码器(静态显示)
- sublime运行python3
- webView的页面下载实现
- HDU 2054 A==B?
- HDU2602 DP + 裸 + 01背包
- C经典 打印垂直三角形
- 60个国外免费3D模型下载网站
- 堆模板
- 使用HTML5中的classList操作CSS类
- 网易互娱2017实习生招聘游戏研发工程师在线笔试第二场(一起消消毒)
- 面试两周的感悟
- UserLocation
- 内部碎片与外部碎片