zoukankan      html  css  js  c++  java
  • 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;
    
    }
    
  • 相关阅读:
    test example
    SSD: ReLU6
    jupyter
    ubuntu+anaconda
    linux动态库
    ssd制作数据和训练
    ncnn框架
    Lock->ReentrantLock->ReentrantReadWriteLock简介
    Synchronized简介与原理
    ThreadLocal简介与原理
  • 原文地址:https://www.cnblogs.com/cxhscst2/p/6359061.html
Copyright © 2011-2022 走看看