题目链接 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. 用NPOI完成公司任务(主要就是导入导出操作)

    注意要先添加程序集的引用 导出到excel: public override IWorkbook writeExecl(string filePath, DataTable dt) { if (Fil ...

  2. Linuxshell编程

    重点回顾: 1.由于核心的内存中是受保护的区块,因此我们必须要透过“shell”将我们输入的指令与Kernel沟通,好让Kernel可以控制硬件来正确无误的工作 2.学习shell的原因主要有:文字接 ...

  3. mysql之处理金钱小数点后的多余0

    问题产生原因:我们在做基金项目   产生大量的金钱  在GP首页展示首页信息的时候要求去除多余的0   由于我们在数据库设计的时候查询返回数据 例如18.100000 这种形式  而我们需要将多余的0 ...

  4. Django补充知识点——用户管理

    内容概要 1.Form表单2.Ajax3.布局,Django母板4.序列化5.Ajax相关6.分页7.XSS攻击8.CSRF9.CBV.FBV 10.类中用装饰器的两种方法 11.上传文件 12.数据 ...

  5. System.AccessViolationException”类型的第一次机会异常在 System.Data.dll 中发生 其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

    管理员cmd中运行  netsh winsock reset

  6. Leetcode 529.扫雷游戏

    扫雷游戏 让我们一起来玩扫雷游戏! 给定一个代表游戏板的二维字符矩阵. 'M' 代表一个未挖出的地雷,'E' 代表一个未挖出的空方块,'B' 代表没有相邻(上,下,左,右,和所有4个对角线)地雷的已挖 ...

  7. redis 集群添加新节点

    准备好需要添加的节点:如何创建节点 启动创建的节点: 启动成功: 添加新节点:redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000  第 ...

  8. 【转】利用Behavior Designer制作敌人AI

    http://www.unity.5helpyou.com/3112.html 本篇unity3d教程,我们来学习下利用Behavior Designer行为树插件来制作敌人AI,下面开始! Beha ...

  9. Ambari API 验证方式

    文章作者:luxianghao 文章来源:http://www.cnblogs.com/luxianghao/p/6123010.html  转载请注明,谢谢合作. 免责声明:文章内容仅代表个人观点, ...

  10. 【bzoj1520】[POI2006]Szk-Schools 费用流

    题目描述 输入 输出 如果有可行解, 输出最小代价,否则输出NIE. 样例输入 5 1 1 2 3 1 1 5 1 3 2 5 5 4 1 5 10 3 3 3 1 样例输出 9 题解 费用流 设xi ...