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 ...
随机推荐
- 关于js拖放功能的实现
这是具体的拖放代码的HTML,里面依赖两个组件:EventUtil.js是兼容浏览器添加方法的库,EventTarget.js是一个发布-订阅者模式的对象库. EventUtil.js: var Ev ...
- 基于Canal和Kafka实现MySQL的Binlog近实时同步
前提 近段时间,业务系统架构基本完备,数据层面的建设比较薄弱,因为笔者目前工作重心在于搭建一个小型的数据平台.优先级比较高的一个任务就是需要近实时同步业务系统的数据(包括保存.更新或者软删除)到一个另 ...
- 编译putty 源码去掉 Are you sure you want to close this session? 提示
0, 为什么要编译 putty ?在关闭窗口的时候,会弹出一个 Are you sure you want to close this session?要把这个去掉.当然也可以用 OD 之类的来修改. ...
- 使用ajax提交登录
引入jquery-1.10.2.js或者jquery-1.10.2.min.js 页面 <h3>后台系统登录</h3> <form name="MyForm&q ...
- flask 密码加密 视频资料
https://www.bilibili.com/video/av53870541/?p=33 通过在数据模型中定义函数来实现加密 from werkzeug.security import gene ...
- Vue2.0 【第三季】第2节 computed Option 计算选项
目录 Vue2.0 [第三季]第2节 computed Option 计算选项 第2节 computed Option 计算选项 一.格式化输出结果 二.用计算属性反转数组 Vue2.0 [第三季]第 ...
- FastDFS源码学习(一)FastDFS介绍及源码编译安装
FastDFS是淘宝的余庆主导开发的一个分布式文件系统,采用C语言开发,性能较优.在淘宝网.京东商城.支付宝和某些网盘等系统均有使用,使用场景十分广泛. 下图来源:https://blog.csdn. ...
- 【Weiss】【第03章】双链表例程
双链表因为多了个前向指针,需要考虑的特殊因素多了一倍 所以中间插入(这儿没写)和中间删除会比较复杂. 其它倒没什么特别的,代码如下. 测试代码 #include <iostream> #i ...
- java猜数游戏(新手记录每天的作业)
//导入包 import java.util.Scanner;import java.util.Random; //定义一个类 public class Zcs{ //公共静态的主方法 public ...
- 面向对象第四单元(UML)及期末总结
前言 统一建模语言(英语:Unified Modeling Language,缩写 UML),是软件架构设计建模和规约的语言. 在UML系统开发中有三个主要的模型: 功能模型:从用户的角度展示系统的功 ...
- HDU 3586 二分答案+树形DP判定