比赛 EYOI常规赛 1st 评测结果 AAAAAAAAAA
题目名称 奶牛晒衣服 最终得分 100
用户昵称 32987018 运行时间 0.254 s
代码语言 C++ 内存使用 3.02 MiB
提交时间 2021-12-15 18:52:08
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn = 500005;
int n;
long long a,b,s[maxn];
bool check(int k) {
    int cnt = 0;
    for(int i = 1;i <= n;++ i) {
        if(s[i] <= (long long)1ll * k * a)continue ;
        long long val = s[i] - (long long)(1ll * k * a);
        cnt += ceil((double)(1.0 * val / (double)b));
    }
    return cnt <= k;
}
int main() {
    freopen("dry.in","r",stdin);
    freopen("dry.out","w",stdout);
    scanf("%d%lld%lld",&n,&a,&b);
    for(int i = 1;i <= n;++ i)scanf("%lld",&s[i]);
    int l = 1,r = maxn,mid;
    while(l <= r) {
        mid = l + r >> 1;
        if(check(mid))r = mid - 1;
        else l = mid + 1;
    }
    printf("%d\n",l);
    fclose(stdin);
    fclose(stdout);
    return 0;
}