WA On #24 求调
查看原帖
WA On #24 求调
938630
Yang_Zicong楼主2024/8/29 20:56
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define rint register int
#define PII pair<int, int>
#define For(i, a, b) for(int i = a;i <= b;i++)
const int N = 1e8;
const int M = 1e4;
const int inf = 0x3f3f3f3f3f3f3f3f;
string sss;
int b, s, c, B, S, C, money, anss;
int bb, ss, cc;
bool judge(int x){
    int res = max((int)(0), x * bb - b) * B + max((int)(0), x * ss - s) * S + max((int)(0), x * cc - c) * C;
    return res <= money;
}
signed main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> sss >> b >> s >> c >> B >> S >> C >> money;
    for (int i = 0; i < sss.size(); i++){
        if (sss[i] == 'B'){
            bb++;
        }
        if (sss[i] == 'S'){
            ss++;
        }
        if (sss[i] == 'C'){
            cc++;
        }
    }
    int l = 0, r = money * 100;
    while (l <= r){
        int mid = (l + r) / 2;
        if (judge(mid)){
            anss = mid;
            l = mid + 1;
        }else{
            r = mid - 1;
        }
    }
    cout << anss;
    return 0;
}
2024/8/29 20:56
加载中...