牛客网 - [牛客假日团队赛6]Charm Bracelet(01背包)
题目链接:https://ac.nowcoder.com/acm/contest/993/H/
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400), a 'desirability' factor Di (1 ≤ Di ≤ 100), and can be used at most once. Bessie can only support a charm bracelet whose weight is no more than M (1 ≤ M ≤ 12,880).
Given that weight limit as a constraint and a list of the charms with their weights and desirability rating, deduce the maximum possible sum of ratings.
输入描述
* Line 1: Two space-separated integers: N and M
* Lines 2..N+1: Line i+1 describes charm i with two space-separated integers: Wi and Di
输出描述
* Line 1: A single integer that is the greatest sum of charm desirabilities that can be achieved given the weight constraints
输入
4 6
1 4
2 6
3 12
2 7
输出
23
解题思路
题意:在最多m权重的情况下求出最大的魅力和。
思路:01背包。
Accepted Code:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 12885;
int dp[MAXN];
int main() {int n, m, w, v;scanf("%d%d", &n, &m);for (int i = 0; i < n; i++) {scanf("%d%d", &w, &v);for (int j = m; j >= w; j--)dp[j] = max(dp[j], dp[j - w] + v);}printf("%d\n", dp[m]);return 0;
}
牛客网 - [牛客假日团队赛6]Charm Bracelet(01背包)相关推荐
- 牛客假日团队赛8:F.Telephone Lines(二分+spfa)
链接:https://ac.nowcoder.com/acm/contest/1069/F 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6553 ...
- 牛客假日团队赛8:H.Cell Phone Network(最小支配集)
链接:https://ac.nowcoder.com/acm/contest/1069/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6553 ...
- 牛客假日团队赛8:K.Cow Contest(最短路(floyd)变形)
链接:https://ac.nowcoder.com/acm/contest/1069/K 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6553 ...
- 牛客假日团队赛5 F 随机数 BZOJ 1662: [Usaco2006 Nov]Round Numbers 圆环数 (dfs记忆化搜索的数位DP)...
链接:https://ac.nowcoder.com/acm/contest/984/F 来源:牛客网 随机数 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6 ...
- 牛客假日团队赛10 L 乘积最大 (dp,大数)
链接:https://ac.nowcoder.com/acm/contest/1072/L?&headNav=acm&headNav=acm 来源:牛客网 乘积最大 时间限制:C/C+ ...
- P5200 [USACO19JAN]Sleepy Cow Sorting 牛客假日团队赛6 D 迷路的牛 (贪心)
链接:https://ac.nowcoder.com/acm/contest/993/E 来源:牛客网 对牛排序 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言 ...
- 牛客假日团队赛6 D 迷路的牛 (思维)
链接:https://ac.nowcoder.com/acm/contest/993/D 来源:牛客网 迷路的牛 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言 ...
- 牛客假日团队赛5J 护城河 bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 (凸包的周长)...
链接:https://ac.nowcoder.com/acm/contest/984/J 来源:牛客网 护城河 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6 ...
- 牛客假日团队赛5 K 金币馅饼 (DP 基础题)
链接:https://ac.nowcoder.com/acm/contest/984/K 来源:牛客网 金币馅饼 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言 ...
- 牛客假日团队赛5 L Catch That Cow HDU 2717 (BFS)
链接:https://ac.nowcoder.com/acm/contest/984/L 来源:牛客网 Catch That Cow 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 3 ...
最新文章
- VTK:图片之ImageGridSource
- [016]转--C++拷贝构造函数详解
- 世界500强高频逻辑推理智力面试题(一)
- 跟我学ASP.NET MVC之五:SportsStrore开始
- C++socket编程(八):8.1 UDP讲解,用户数据报协议
- Ubuntu 12.04下Pomelo开发环境搭建(转)
- 中国芝麻市场竞争规模及销售渠道分析报告2022-2028年版
- java web 测试要点记录
- 国际高智商组织门萨的智商测试题-谋杀你的脑细胞
- 赛码-回文串-java
- 新浪微博PC客户端(DotNet WinForm版)——功能实现分解介绍
- 程序员的发展之道---海贼王(山治)
- 3dsmax-角色骨骼
- 电子制作——锂电池大功率充电器
- TextOut 字符串输出
- mysql默认民族_56个民族及民族代码的sql语句
- 实时数仓在滴滴的实践和落地
- 奥塔在线:CentOS下查看crontab定时任务输出日志
- 中子测井之热中子、超热中子和补偿中子测井基本原理
- zt:太阳上挖煤的可行性报告
热门文章
- 计算机注册表命令,进入注册表的方法和命令(电脑的注册表怎么打开)
- vue给文字加下划线
- 李开复写给中国大学生的信
- log4j2.xml 配置文件详解
- 杭州电子科技大学计算机考研录取名单,杭州电子科技大学2017年硕士研究生一志愿考生复试名单公布...
- win7 x64怎么枚举所有快捷键呢
- EPLAN2.9程序安装及注意事项
- 华为薪资等级结构表2020_[新版文件]2020年华为员工标准岗位工资明细及分析
- 移远UMTS LTE EVB Kit
- 数独大师级技巧_零基础入手攻克专家级数独难题实战案例