結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー momoyuumomoyuu
提出日時 2023-03-16 02:57:06
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 313 ms / 3,000 ms
コード長 1,228 bytes
コンパイル時間 4,174 ms
コンパイル使用メモリ 251,368 KB
実行使用メモリ 4,868 KB
最終ジャッジ日時 2023-10-18 12:48:02
合計ジャッジ時間 11,957 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 283 ms
4,868 KB
testcase_05 AC 313 ms
4,868 KB
testcase_06 AC 134 ms
4,868 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 183 ms
4,348 KB
testcase_09 AC 252 ms
4,612 KB
testcase_10 AC 93 ms
4,348 KB
testcase_11 AC 82 ms
4,348 KB
testcase_12 AC 12 ms
4,348 KB
testcase_13 AC 187 ms
4,348 KB
testcase_14 AC 224 ms
4,516 KB
testcase_15 AC 291 ms
4,868 KB
testcase_16 AC 79 ms
4,348 KB
testcase_17 AC 143 ms
4,348 KB
testcase_18 AC 127 ms
4,348 KB
testcase_19 AC 85 ms
4,348 KB
testcase_20 AC 65 ms
4,348 KB
testcase_21 AC 196 ms
4,604 KB
testcase_22 AC 258 ms
4,636 KB
testcase_23 AC 302 ms
4,868 KB
testcase_24 AC 307 ms
4,868 KB
testcase_25 AC 291 ms
4,868 KB
testcase_26 AC 303 ms
4,868 KB
testcase_27 AC 307 ms
4,868 KB
testcase_28 AC 303 ms
4,868 KB
testcase_29 AC 302 ms
4,868 KB
testcase_30 AC 288 ms
4,868 KB
testcase_31 AC 302 ms
4,868 KB
testcase_32 AC 306 ms
4,868 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 3 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    ll a,b,x,y;
    cin>>n>>a>>b>>x>>y;
    vector<ll> h(n);
    for(int i = 0;i<n;i++) cin>>h[i];
    ll l = -1;
    ll r = 1e9;
    while(r-l>1){
        ll mid = (r+l) / 2;
        vector<ll> now(n);
        for(int i = 0;i<n;i++) now[i] = max(0LL,h[i]-mid);
        ll ra = a,rb = b;
        ll cnt = 0;
        for(int i = 0;i<n;i++){
            ll want = now[i] / x;
            if(want+cnt<=a){
                now[i] -= x * want;
                cnt += want;
            }else{
                ll can = a - cnt;
                now[i] -= x * can;
                cnt += can;
            }
        }
        sort(now.begin(),now.end());
        reverse(now.begin(),now.end());
        for(int i = 0;i<n;i++){
            if(now[i]!=0&&cnt+1<=a){
                cnt++;
                now[i] = 0;
            }
        }
        ll rest = b * y;
        for(int i = 0;i<n;i++){
            ll can = min(now[i],rest);
            now[i] -= can;
            rest -= can;
        }
        bool p = true;
        for(int i = 0;i<n;i++) if(now[i]!=0) p = false;
        if(p) r = mid;
        else l = mid;
    }
    cout<<r<<endl;
}
0