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逆向-滑动验证码图片还原
本文列举两个例子:某象和某验的滑动验证 一.某验:aHR0cHM6Ly93d3cuZ2VldGVzdC5jb20vZGVtby9zbGlkZS1mbG9hdC5odG1s 未还原图像: 还原后的图: ...
- 使用AQS自定义重入锁
一.创建MyLock import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.AbstractQueuedSyn ...
- HTTP GET请求302重定向问题
1.问题描述 ① 在华为云服务器中搭建了java环境,并在tomcat中部署了一个空的web项目 ② 在此web项目中上传了一个名为:plugin_DTDREAM_LIVING_DEHUMIDIFIE ...
- 关于.NET中的控制反转及AutoFac的简单说明
目录 1.控制反转 1.1 什么是依赖? 1.2 什么是控制反转? 1.3 什么是依赖注入? 1.4 简单总结 2.控制反转容器 2.1 IOC容器说明 2.2 使用AutoFac的简介示例 3 使用 ...
- js 数组一些简单应用
把两个数组连接成按从小到大的一个数组例如: var allowVlan = '23-25,45,4-6,67,50-53'; var unTagVlan = '1-5'; 完成时应该是1-6,23-2 ...
- jQuery实现颜色打字机
效果:每个字逐个显示出来,并且每个字都有随机颜色 $(function(){ var str="早起的鸟儿有虫吃,早起的虫儿被鸟吃!由此天赋+勤奋=成功;先天不足+同等勤奋=还是失败!天赋的 ...
- 从火箭发场景来学习Java多线程并发闭锁对象
从火箭发场景来学习Java多线程并发闭锁对象 倒计时器场景 在我们开发过程中,有时候会使用到倒计时计数器.最简单的是:int size = 5; 执行后,size—这种方式来实现.但是在多线程并发的情 ...
- 用 SendGrid 发送免费电子邮件
1. 概述 SendGrid 免费账号可以限额发送 100/天封邮件,虽然比 Mailgun 的每月 10000 封的免费额度少,但胜成注册无需绑定信息卡. 集成 SendGrid 有 SMTP 和 ...
- 项目中 关于localstorage、cookie的坑?明明设置了本地存储为什么没生效
1.简单的介绍一下localStorage,sessionStorage,cookie localStorage:仅在客户端存储不参与服务器通信,存储大小一般为5M,如果不是人为清除,那么即使是关闭浏 ...
- Flask wtforms 表单验证使用
目录 wtforms 使用1(简单版): 使用2(复杂版): wtforms 安装:pip3 install wtforms 使用1(简单版): from flask import Flask, re ...
- HDU 3586 二分答案+树形DP判定