题目链接 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 (二分答案)的更多相关文章

  1. CodeForces 371C Hamburgers(经典)【二分答案】

    <题目链接> 题目大意: 给以一段字符串,其中只包含"BSC"这三个字符,现在有一定量免费的'B','S','C‘,然后如果想再买这三个字符,就要付出相应的价格.现在总 ...

  2. 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 ...

  3. CodeForces 371C Hamburgers

    B题又耽误时间了...人太挫了.... C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes i ...

  4. Mr. Kitayuta vs. Bamboos CodeForces - 505E (堆,二分答案)

    大意: 给定$n$棵竹子, 每棵竹子初始$h_i$, 每天结束时长$a_i$, 共$m$天, 每天可以任选$k$棵竹子砍掉$p$, 若不足$p$则变为0, 求$m$天中竹子最大值的最小值 先二分答案转 ...

  5. Codeforces 700A As Fast As Possible(二分答案)

    [题目链接] http://codeforces.com/problemset/problem/700/A [题目大意] 有一辆限载k人速度为v2的车,n个步行速度均为v1的人要通过一段长度为l的距离 ...

  6. Codeforces Round #276 (Div. 1) E. Sign on Fence (二分答案 主席树 区间合并)

    链接:http://codeforces.com/contest/484/problem/E 题意: 给你n个数的,每个数代表高度: 再给出m个询问,每次询问[l,r]区间内连续w个数的最大的最小值: ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. SpringMVC基本概念

    DispatcherServlet:MVC的前端控制器,浏览器用户的请求经过DispatcherServlet的分发,到达合适的controller,生产业务数据所需要的model,model通过Di ...

  2. 如何部署安装软件:vs2010 'VS' Inno Setup

    一直以来就是调试程序,生成的文件在debug或者release下,当没有其他资源文件时,这些程序也不用打包,直接就能够运行,但是程序中总会有一些额外的资源文件,视频啊,图片啊.这些需要打包在一个安装文 ...

  3. Kafka SSL 配置

    #!/bin/bash # 生成服务器keystore(密钥和证书)keytool -keystore server.keystore.jks -alias machine03.zheng.com - ...

  4. 理解机器为什么可以学习(五)---Noise and Error

    之前我们讨论了VC Dimension,最终得到结论,如果我们的hypetheset的VC Dimension是有限的,并且有足够的资料,演算法能够找到一个hypethesis,它的Ein很低的话,那 ...

  5. yum 快速安装 Rabbitmq for CentOS6

    1.安装CENTOS6的系统. 2.配置源 ,说明:https://github.com/rabbitmq/erlang-rpm To use Erlang 20.x on CentOS 6: # I ...

  6. sqlserver中top 1 赋值的问题

    看代码 declare @iid intselect @iid=111select top 1 @iid=isnull(IID,0) from YYGL_PCDMX where IID=0print ...

  7. ValueStack、ActionContext

    笔者不知道该用哪个词来形容ValueStack.ActionContext等可以在Struts2中用来存放数据的类.这些类使用的范围不同,得到的方法也不同,下面就来一一介绍. 1. ValueStac ...

  8. 【bzoj4399】魔法少女LJJ 并查集+权值线段树合并

    题目描述 在森林中见过会动的树,在沙漠中见过会动的仙人掌过后,魔法少女LJJ已经觉得自己见过世界上的所有稀奇古怪的事情了LJJ感叹道“这里真是个迷人的绿色世界,空气清新.淡雅,到处散发着醉人的奶浆味: ...

  9. 【bzoj3930】[CQOI2015]选数 莫比乌斯反演+杜教筛

    题目描述 我们知道,从区间[L,H](L和H为整数)中选取N个整数,总共有(H-L+1)^N种方案.小z很好奇这样选出的数的最大公约数的规律,他决定对每种方案选出的N个整数都求一次最大公约数,以便进一 ...

  10. chrome浏览器无法安装非应用商店插件的解决办法

    不久前,安装了一个非chrome应用商店的第三方应用,今天突然发现无法使用,打开chrome的扩展程序后,发现该插件以及被禁用,在网上查找了解决方法,设置“开发者模式”,修改了chrome的参数,仍然 ...