U - Inviting Friends HDU - 3244(二分答案 + 完全背包)
U - Inviting Friends HDU - 3244
You want to hold a birthday party, inviting as many friends as
possible, but you have to prepare enough food for them. For each
person, you need n kinds of ingredient to make good food. You can use
the ingredients in your kitchen, or buy some new ingredient packages.
There are exactly two kinds of packages for each kind of ingredient:
small and large.We use 6 integers to describe each ingredient: x, y, s1, p1, s2, p2,
where x is the amount (of this ingredient) needed for one person, y is
the amount currently available in the kitchen, s1 and p1 are the size
(the amount of this ingredient in each package) and price of small
packages, s2 and p2 are the size and price of large packages.Given the amount of money you can spend, your task is to find the
largest number of person who can serve. Note that you cannot buy only
part of a package. Input There are at most 10 test cases. Each case
begins with two integers n and m (1<=n<=100, 1<=m<=100000), the number
of kinds of ingredient, and the amount of money you have. Each of the
following n lines contains 6 positive integers x, y, s1, p1, s2, p2 to
describe one kind of ingredient (10<=x<=100, 1<=y<=100, 1<=s1<=100,
10<=p1<=100, s1<s2<=100, p1<p2<=100). The input ends with n = m = 0.
Output For each test case, print the maximal number of people you can
serve. Sample Input
2 100
10 8 10 10 13 11
12 20 6 10 17 24
3 65
10 5 7 10 13 14
10 5 8 11 14 15
10 5 9 12 15 16
0 0
Sample Output
5
2
思路
- 这一题挺不错的,把 二分的知识 与 背包问题的知识放在一起来考察我们,这一题我们要二分的是 招待的 friend 的数量, 而我们一但二分答案假设出一个 朋友数量,我们就需要判断 用厨房里剩余的菜 + 手里的钱
U - Inviting Friends HDU - 3244(二分答案 + 完全背包)的更多相关文章
- HDU 3586 二分答案+树形DP判定
HDU 3586 『Link』HDU 3586 『Type』二分答案+树形DP判定 ✡Problem: 给定n个敌方据点,1为司令部,其他点各有一条边相连构成一棵树,每条边都有一个权值cost表示破坏 ...
- U - Inviting Friends HDU - 3244( LIS 最长升序子序列——变形 )
序列变换 Problem Description 我们有一个数列A1,A2-An,你现在要求修改数量最少的元素,使得这个数列严格递增.其中无论是修改前还是修改后,每个元素都必须是整数. 请输出最少需要 ...
- 分数规划模板(洛谷P4377 [USACO18OPEN]Talent Show)(分数规划,二分答案,背包)
分数规划是这样一个东西: 给定若干元素,每个元素有两个属性值\(a_i,b_i\),在满足题目要求的某些限制下选择若干元素并求出\(\frac{\sum a}{\sum b}\)的最大值. 如果没有限 ...
- HDU 5884 Sort(二分答案+计算WPL的技巧)
Sort Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- Hdu Can you find it?(二分答案)
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others) P ...
- HDU 5649 DZY Loves Sorting(二分答案+线段树/线段树合并+线段树分割)
题意 一个 \(1\) 到 \(n\) 的全排列,\(m\) 种操作,每次将一段区间 \([l,r]\) 按升序或降序排列,求 \(m\) 次操作后的第 \(k\) 位. \(1 \leq n \le ...
- Maximum Shortest Distance 最大团 二分答案 HDU 3585
题意:给出n个点 要求取k个点 这k个点中 距离最小的两个点要求距离最大 拿到手看不出是最大团 也看不出是二分答案(第一次用) 因为答案必然存在 一定有一个最值 所以用二分答案来做 最大距 ...
- HDU - 5884 Sort (二分答案+贪心)
有n个数字,你需要把这n个数字合成一个数字,每次只能把k个数字合并成一个,花费为这k个数字的和. 给一个最大花费,问不超过这个最大花费的情况下,k的最小值. Sample Input 1 5 25 1 ...
- HDU 1551 Cable master【二分答案】
题意:给出n块木板,它们分别的高度,现在要把它们裁切成k块,问裁切成的最大的高度 二分答案,上限是这n块木板里面的最大值 然后每一个答案去判断一下是否满足能够裁切成k块 #include<ios ...
随机推荐
- 【04】openlayers 地图弹框
效果: 创建地图: //创建地图 var map = new ol.Map({ //设置显示地图的视图 view: new ol.View({ projection: 'EPSG:4326', //投 ...
- 借助Redis完成延时任务
背景 相信我们或多或少的会遇到类似下面这样的需求: 第三方给了一批数据给我们处理,我们处理好之后就通知他们处理结果. 大概就是下面这个图说的. 本来在处理完数据之后,我们就会马上把处理结果返回给对方, ...
- 5G 将带给程序员哪些新机会呢?
5G,第 5 代移动通信技术,华为在此领域远远领先同行,这也让它成了中美贸易战的最前线.我的第一份工作就在通信行业,当时电信标准都在欧美企业手里,国内企业主要是遵照标准研发软硬件设备,核心芯片靠进口. ...
- vue中nextTick的使用场景
https://blog.csdn.net/bingqise5193/article/details/100212278
- 动态高度计算 height window.addEventListener('resize', () => {
created() { window.addEventListener('resize', () => { }) },
- el-dialog对话弹框中根据后台数据无限制添加el-select标签,并进行展示,搜索,删除
前几天遇到一个题,el-dialog对话弹框中根据后台数据无限制添加el-select标签,并进行展示,搜索,删除,在这上面用到了递归算法,废话不多说,直接上代码 <template> & ...
- seldom之数据驱动
seldom之数据驱动 如果自动化某个功能,测试数据不一样而操作步骤是一样的,那么就可以使用参数化来节省测试代码. seldom是我在维护一个Web UI自动化测试框,这里跟大家分享seldom参数化 ...
- IntegerCache缓存占用堆、栈、常量池的问题,自动拆装箱的基本概念,Integer==int时的问题说明
原创声明:作者:Arnold.zhao 博客园地址:https://www.cnblogs.com/zh94 先普及一个基本概念:Java中基本数据类型的装箱和拆箱操作 自动装箱 在JDK5以后,我们 ...
- python,keras,tensorflow安装问题 module 'tensorflow' has no attribute 'get_default_graph'
module ‘tensorflow’ has no attribute ‘get_default_graph’当我使用keras和tensorflow做深度学习的时候,python3.7报了这个错误 ...
- prometheus远程写参数优化
一.概述 prometheus可以通过远程存储来解决自身存储的瓶颈,所以其提供了远程存储接口,并可以通过过配置文件进行配置(prometheus.yml).一般情况下我们使用其默认的配置参数,但是为了 ...
- HDU 3586 二分答案+树形DP判定