二分搜索 Codeforces Round #218 (Div. 2) C. Hamburgers
/*
题意:一个汉堡制作由字符串得出,自己有一些原材料,还有钱可以去商店购买原材料,问最多能做几个汉堡
二分:二分汉堡个数,判断此时所花费的钱是否在规定以内
*/
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std; typedef long long ll;
const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
char ham[MAXN];
ll nb, ns, nc;
ll pb, ps, pc;
ll b, s, c;
ll m; bool check(ll x) {
ll cost = ;
if (b * x > nb) cost += (b * x - nb) * pb;
if (s * x > ns) cost += (s * x - ns) * ps;
if (c * x > nc) cost += (c * x - nc) * pc;
return cost <= m;
} int main(void) { //Codeforces Round #218 (Div. 2) C. Hamburgers
scanf ("%s", &ham);
scanf ("%I64d%I64d%I64d", &nb, &ns, &nc);
scanf ("%I64d%I64d%I64d", &pb, &ps, &pc);
scanf ("%I64d", &m);
b = s = c = ;
for (int i=; ham[i]; ++i) {
if (ham[i] == 'B') b++;
else if (ham[i] == 'S') s++;
else c++;
}
ll l = , r = 1e13;
while (l + < r) {
ll mid = (l + r) >> ;
if (check (mid)) l = mid;
else r = mid;
}
printf ("%I64d\n", l); return ;
}
二分搜索 Codeforces Round #218 (Div. 2) C. Hamburgers的更多相关文章
- Codeforces Round #218 (Div. 2) C. Hamburgers
C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- Codeforces Round #218 (Div. 2)
500pt, 题目链接:http://codeforces.com/problemset/problem/371/A 分析:k-periodic说明每一段长度为k,整个数组被分成这样长度为k的片段,要 ...
- Codeforces Round #218 (Div. 2) C题
C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #218 (Div. 2) D. Vessels
D. Vessels time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...
- Codeforces Round #218 (Div. 2) B. Fox Dividing Cheese
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #218 (Div. 2) (线段树区间处理)
A,B大水题,不过B题逗比了题意没理解清楚,讲的太不清楚了感觉= =还是英语弱,白白错了两发. C: 二分答案判断是否可行,也逗比了下...二分的上界开太大导致爆long long了... D: ...
- Codeforces Round #404 (Div. 2) C 二分查找
Codeforces Round #404 (Div. 2) 题意:对于 n and m (1 ≤ n, m ≤ 10^18) 找到 1) [n<= m] cout<<n; 2) ...
- 刷题记录:Codeforces Round #725 (Div. 3)
Codeforces Round #725 (Div. 3) 20210704.网址:https://codeforces.com/contest/1538. 感觉这个比上一个要难. A 有一个n个数 ...
随机推荐
- Eclipse4.5在线安装Aptana插件及配置代码提示教程
一.Aptana插件官网地址 我在网上试过登陆到aptana官网后点击下载,选择下载eclipse插件版,然后页面给出一串地址:http://download.aptana.com/s ...
- 【Intellij 】Intellij IDEA 添加jar包的三种方式
一.直接复制:(不推荐) 方法:直接将硬盘上的jar包复制粘贴到项目的lib目录下即可. 注意: 1.对于导入的eclipse项目,该方式添加的jar包没有任何反应,用make编译项目会报错 2.对于 ...
- FZU Problem 2132 LQX的作业 (数学题)
http://acm.fzu.edu.cn/problem.php?pid=2132 N个数已经排成非递减顺序,那么每次可以取 前m->n个在x前面.取前m个在x前面的概率是 C(n,m)*x^ ...
- MongoDB小结20 - find【查询条件$size】
size可以获得指定数组长度的文档 db.user.find({"fruit":{"$size":3}},{"_id":0}) { &quo ...
- Utuntu下Xshell使用+vi使用
记得上次Utuntu下Xshell环境没有搭建成功,这个又试试! 按照以前的方法测试Utuntu的ip;在本机安装Xshell 然后出现xshell连接虚拟机时,提示SSH服务器拒绝了密码 修改方法: ...
- Django学习系列之ORM-QuerySetAPI
基本操作 # 增 models.Tb1.objects.create(c1='xx', c2='oo') #增加一条数据,可以接受字典类型数据 **kwargs obj = models.Tb1(c1 ...
- CentOS firewall添加开放端口
添加 firewall-cmd --zone=public --add-port=80/tcp --permanent (–permanent永久生效,没有此参数重启后失效) 重新载入 firewal ...
- linux设备驱动归纳总结(八):2.match.probe.remove
linux设备驱动归纳总结(八):2.总线.设备和驱动的关系 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- S5P4418裸机开发系列教程--源代码下载
S5P4418裸机系列教程之stdio S5P4418裸机系列教程之shell命令行 S5P4418裸机系列教程之串口回显 S5P4418裸机系列教程之复位測试 S5P4418裸机系列教程之led跑马 ...
- Android学习笔记-junit单元测试
我们都知道测试对于程序员来说是必不可少的,所以,做Android程序,也要学会使用junit,这里比着java的junit测试,要稍微复杂一点,需要一些配置,下面饿哦就介绍一下怎样使用junit的测试 ...