結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー ace_amuroace_amuro
提出日時 2023-04-11 14:07:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 836 ms / 3,000 ms
コード長 1,093 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 85,348 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 12:24:35
合計ジャッジ時間 18,815 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 674 ms
5,376 KB
testcase_05 AC 836 ms
5,376 KB
testcase_06 AC 368 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 446 ms
5,376 KB
testcase_09 AC 537 ms
5,376 KB
testcase_10 AC 187 ms
5,376 KB
testcase_11 AC 212 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 496 ms
5,376 KB
testcase_14 AC 585 ms
5,376 KB
testcase_15 AC 718 ms
5,376 KB
testcase_16 AC 202 ms
5,376 KB
testcase_17 AC 369 ms
5,376 KB
testcase_18 AC 261 ms
5,376 KB
testcase_19 AC 97 ms
5,376 KB
testcase_20 AC 161 ms
5,376 KB
testcase_21 AC 381 ms
5,376 KB
testcase_22 AC 639 ms
5,376 KB
testcase_23 AC 769 ms
5,376 KB
testcase_24 AC 829 ms
5,376 KB
testcase_25 AC 655 ms
5,376 KB
testcase_26 AC 808 ms
5,376 KB
testcase_27 AC 756 ms
5,376 KB
testcase_28 AC 805 ms
5,376 KB
testcase_29 AC 769 ms
5,376 KB
testcase_30 AC 711 ms
5,376 KB
testcase_31 AC 810 ms
5,376 KB
testcase_32 AC 811 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 3 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e5+10;
int n,A,B,X,Y,h[MR];
int b[MR];
bool cmp(int x,int y){
    return x%X>y%X;
}
bool check(int k){
    int a=A;
    LL sum=0;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(h[i]<=k) continue;
        cnt++;
        b[cnt]=h[i]-k;
    }
    sort(b+1,b+cnt+1,cmp);
    for(int i=1;i<=cnt;i++){
        if(a>=b[i]/X){
            a-=b[i]/X;
            b[i]%=X;
        }
        else if(a>0){
            b[i]-=a*X;
            a=0;
            break;
        }
    }
    for(int i=a+1;i<=cnt;i++){
        sum+=b[i];
    }
    return sum<=1ll*B*Y;
}

int main(){
    cin>>n>>A>>B>>X>>Y;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    int l=-1,r=1e9+10;
    while(l+1<r){
        int mid=(l+r)/2;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout<<r<<endl;
    return 0;
}
0