結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー abc3abc3
提出日時 2021-11-13 15:16:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 763 ms / 3,000 ms
コード長 1,537 bytes
コンパイル時間 1,992 ms
コンパイル使用メモリ 205,696 KB
実行使用メモリ 4,824 KB
最終ジャッジ日時 2023-08-18 07:51:14
合計ジャッジ時間 15,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 472 ms
4,668 KB
testcase_05 AC 763 ms
4,704 KB
testcase_06 AC 103 ms
4,552 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 206 ms
4,376 KB
testcase_09 AC 254 ms
4,376 KB
testcase_10 AC 229 ms
4,380 KB
testcase_11 AC 132 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 284 ms
4,380 KB
testcase_14 AC 494 ms
4,436 KB
testcase_15 AC 416 ms
4,720 KB
testcase_16 AC 344 ms
4,376 KB
testcase_17 AC 204 ms
4,376 KB
testcase_18 AC 382 ms
4,376 KB
testcase_19 AC 46 ms
4,380 KB
testcase_20 AC 87 ms
4,380 KB
testcase_21 AC 187 ms
4,380 KB
testcase_22 AC 397 ms
4,444 KB
testcase_23 AC 432 ms
4,804 KB
testcase_24 AC 738 ms
4,516 KB
testcase_25 AC 673 ms
4,636 KB
testcase_26 AC 480 ms
4,700 KB
testcase_27 AC 723 ms
4,632 KB
testcase_28 AC 495 ms
4,660 KB
testcase_29 AC 730 ms
4,572 KB
testcase_30 AC 521 ms
4,720 KB
testcase_31 AC 541 ms
4,768 KB
testcase_32 AC 735 ms
4,824 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    const ll INF=1001001001;
    const int mod=1e9+7;

    void solve(){
        ll n,a,b,x,y;
        cin>>n>>a>>b>>x>>y;
        vector<ll>h(n);
        rep(i,n)cin>>h[i];
        
        auto f=[&](int k){
            priority_queue<int>q;
            rep(i,n){
                if(h[i]-k<=0){continue;}
                q.push(h[i]-k);
            }
            rep(i,a){
                if(q.empty()){break;}
                int p=q.top();q.pop();
                p-=x;
                if(p>0){q.push(p);}
            }
            ll sum=0;
            while(!q.empty()){
                int p=q.top();q.pop();
                sum+=p;
            }
            return sum<=b*y;
        };
        
        int l=-1,r=1e9+5;
        while(r-l>1){
            int mid=(l+r)/2;
            if(f(mid)){r=mid;}
            else{l=mid;}
        }
        cout<<r<<endl;
    }  

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve(); 

        return 0;
    }
0