Codeforces 371C Hamburgers (二分答案)
题目链接 Hamburgers
二分答案,贪心判断即可。
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i(0); i < (n); ++i)
#define LL long long char str[1010];
LL len;
LL b, c, s, nb, nc, ns, pb, pc, ps;
LL money; bool judge(LL x){
LL mb = x * b;
LL ms = x * s;
LL mc = x * c; LL now_money = money;
if (mb > nb) now_money -= (mb - nb) * pb;
if (ms > ns) now_money -= (ms - ns) * ps;
if (mc > nc) now_money -= (mc - nc) * pc; return now_money >= 0LL;
} int main(){ scanf("%s", str);
len = strlen(str);
REP(i, len){
if (str[i] == 'B') ++b;
else if (str[i] == 'S') ++s;
else ++c;
} cin >> nb >> ns >> nc;
cin >> pb >> ps >> pc;
cin >> money; LL l = 0, r = 1e14;
while (l + 1 < r){
LL mid = (l + r) / 2;
if (judge(mid)) l = mid; else r = mid - 1;
} if (judge(r)) cout << r << endl; else cout << l << endl;
return 0; }
Codeforces 371C Hamburgers (二分答案)的更多相关文章
- CodeForces 371C Hamburgers(经典)【二分答案】
<题目链接> 题目大意: 给以一段字符串,其中只包含"BSC"这三个字符,现在有一定量免费的'B','S','C‘,然后如果想再买这三个字符,就要付出相应的价格.现在总 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划
There are n people and k keys on a straight line. Every person wants to get to the office which is l ...
- CodeForces 371C Hamburgers
B题又耽误时间了...人太挫了.... C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes i ...
- Mr. Kitayuta vs. Bamboos CodeForces - 505E (堆,二分答案)
大意: 给定$n$棵竹子, 每棵竹子初始$h_i$, 每天结束时长$a_i$, 共$m$天, 每天可以任选$k$棵竹子砍掉$p$, 若不足$p$则变为0, 求$m$天中竹子最大值的最小值 先二分答案转 ...
- Codeforces 700A As Fast As Possible(二分答案)
[题目链接] http://codeforces.com/problemset/problem/700/A [题目大意] 有一辆限载k人速度为v2的车,n个步行速度均为v1的人要通过一段长度为l的距离 ...
- Codeforces Round #276 (Div. 1) E. Sign on Fence (二分答案 主席树 区间合并)
链接:http://codeforces.com/contest/484/problem/E 题意: 给你n个数的,每个数代表高度: 再给出m个询问,每次询问[l,r]区间内连续w个数的最大的最小值: ...
- Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论
n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...
- Codeforces 772A Voltage Keepsake - 二分答案
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per s ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature【枚举二分答案】
https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the rea ...
随机推荐
- BFS:HDU3085-Nightmare Ⅱ(双向BFS)
Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- Java语言基础---逻辑运算(长路短路运算)
长路短路运算的区别 长路与运算&:是指在两边都是整数时,是逐位与运算,在两边是关系运算时,是逻辑运算. 短路与运算&&:是指从左至右,遇到false,则停止后面的运算. 长路或 ...
- 3 View视图 URLconf
1.视图 视图接受Web请求并且返回Web响应 视图就是一个python函数,被定义在views.py中 响应可以是一张网页的HTML内容,一个重定向,一个404错误等等 响应处理过程如下图: 2 准 ...
- Java之基于Apache jar包的FTPClient上传
首先,准备工作: http://pan.baidu.com/s/1dD1Utwt 从以上链接下载Apache的jar包,并将其复制到工程的WEB-INF下的lib包里,在此,准备工作就已经完成了. 具 ...
- IOS开发学习笔记032-UITableView 的编辑模式
UITableView 的三种编辑模式 1.删除 2.排序 3.添加 进入编辑模式,需要设置一个参数 - (IBAction)remove:(UIBarButtonItem *)sender { NS ...
- Python+Selenium练习篇之21-如何截图并保存
本文介绍如何利用Selenium的方法进行截图,在测试过程中,是有必要截图,特别是遇到错误的时候进行截图.在selenium for python中主要有三个截图方法,我们挑选其中最常用的一种. ge ...
- maven文件报错(pom.xml或者jar包缺失)解决方法
相信很多朋友在myeclipse上把maven配置好了,但是新建maven项目的时候会报错,下面我来总结以下我遇到的问题. 新建完maven项目后,pom.xml报错 1.报错的原因:很多时候我们在下 ...
- 数据结构之c++感悟
#include<iostream.h> 头文件: #include<iostream.h> #define MAX 1024 typedef int Elemtype; ty ...
- Leetcode 558.四叉树交集
四叉树交集 四叉树是一种树数据,其中每个结点恰好有四个子结点:topLeft.topRight.bottomLeft 和 bottomRight.四叉树通常被用来划分一个二维空间,递归地将其细分为四个 ...
- mysql数据库二进制初始化出现:170425 17:47:04 [ERROR] /application/mysql//bin/mysqld: unknown option '--skip-locking' 170425 17:47:04 [ERROR] Aborting 解决办法
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --data ...