简单dp-bone collector
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 ?
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.
1 5 10 1 2 3 4 5 5 4 3 2 1
Sample Output
14
Hint
By AC_gsws
![](/assets/blank.gif)
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int T;
int m, n;
const int maxn = 1010;
int dp[maxn][maxn], v[maxn], w[maxn];
int main()
{scanf("%d", &T);while (T--){scanf("%d%d", &n, &m);memset(dp, 0, sizeof(dp));for (int i = 1; i <= n; i++){scanf("%d", &v[i]);}for (int j = 1; j <= n; j++){scanf("%d", &w[j]);}for (int i = 1; i <= n; i++){for (int j = m; j >=0; j--){if (j < w[i]) dp[i][j] = dp[i - 1][j];else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);}}printf("%d\n", dp[n][m]);}return 0;
}
有问题欢迎私聊哦~么么哒
简单dp-bone collector相关推荐
- HDU 2602 Bone Collector DP(01背包)
Bone Collector Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Desc ...
- HDU2602 Bone Collector【0/1背包+DP】
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- NUC-ACM/ICPC 寒假训练 简单DP A - G题
第一题:数塔 HDU - 2084 做法: 从第 i , j 个 节点往下走的最优解可以由从第 i+1,j 个节点往下走的最优解和第i+1,j+1个节点往下走的最优解得出,二者取其优即可. 代码: 记 ...
- hdu 2602 Bone Collector 01背包
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU Problem 2062 Bone Collector【01背包】
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HD 2602 Bone Collector (0-1背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , in Teddy's ...
- hdu 2602 Bone Collector(01背包)模板
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...
- Bone Collector(HDU-2602)
Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...
- Bone collector//动态规划
题目 Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- Bone Collector(01背包问题-两种写法)
Many years ago , in Teddy's hometown there was a man who was called "Bone Collector". This ...
最新文章
- Swift 圆环进度条
- DIY Ruby CPU 分析 Part III
- python能够做什么软件-python爬虫软件有哪些做的比较好的?
- linux generic什么意思_如何在 Ubuntu 中修复 VirtualBox 的 “rc=1908” 错误 | Linux 中国...
- Java程序员技能树
- 孙鑫VC学习笔记:第十三讲 (六) 关于释放内存
- 2011年工作安排_计算机技术与软件专业技术资格考试
- 通过自定义注解+反射的形式,使用POI实现excel的导入导出
- LC-3简易四子棋(深大计系1实验4) 思路+代码+详细注释
- 基于TensorRT和onnxruntime下pytorch的Bert模型加速对比实践
- c++ findpeaks函数_C++实现MATLAB一维数组函数findpeaks()函数求一维离散值极值(波峰波谷)...
- re 正则表达式匹配中文
- LeetCode05最长回文子串
- math: 凸函数、拟凸函数和保凸运算
- 【量化投资】高频交易(HFT),下一个风口?
- Dynamics 365 On-premises Field Service的安装试用问题
- html仿短信聊天,前端开发JS模仿手机短信发送
- 如何挖掘网站的长尾关键词?
- json和字典之间的转换
- 视野:产业链,价值链,核心竞争力