結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー nawawannawawan
提出日時 2021-11-12 21:56:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 586 ms / 3,000 ms
コード長 932 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 206,060 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 08:31:38
合計ジャッジ時間 11,855 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 490 ms
6,940 KB
testcase_05 AC 464 ms
6,944 KB
testcase_06 AC 160 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 204 ms
6,944 KB
testcase_09 AC 252 ms
6,944 KB
testcase_10 AC 156 ms
6,944 KB
testcase_11 AC 141 ms
6,940 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 292 ms
6,940 KB
testcase_14 AC 315 ms
6,940 KB
testcase_15 AC 442 ms
6,940 KB
testcase_16 AC 169 ms
6,940 KB
testcase_17 AC 208 ms
6,944 KB
testcase_18 AC 136 ms
6,940 KB
testcase_19 AC 53 ms
6,940 KB
testcase_20 AC 78 ms
6,944 KB
testcase_21 AC 196 ms
6,940 KB
testcase_22 AC 405 ms
6,940 KB
testcase_23 AC 456 ms
6,940 KB
testcase_24 AC 586 ms
6,944 KB
testcase_25 AC 329 ms
6,944 KB
testcase_26 AC 498 ms
6,944 KB
testcase_27 AC 378 ms
6,940 KB
testcase_28 AC 513 ms
6,940 KB
testcase_29 AC 419 ms
6,944 KB
testcase_30 AC 514 ms
6,940 KB
testcase_31 AC 555 ms
6,940 KB
testcase_32 AC 437 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 3 ms
6,940 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long A, B, X, Y;
    cin >> A >> B >> X >> Y;
    vector<long long> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    long long ub = 1000000000, lb = -1;
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;
        priority_queue<long long> q;
        for(int i = 0; i < N; i++) {
            if(H[i] > mid) q.push(H[i] - mid);
        }
        long long a = A;
        while(!q.empty() && a > 0){
            long long temp = q.top();
            q.pop();
            int cnt = min(temp / X, a);
            if(cnt == 0) cnt++;
            temp -= X * cnt;
            if(temp > 0) q.push(temp);
            a -= cnt;
        }
        long long sum = 0;
        while(!q.empty()){
            sum += q.top();
            q.pop();
        }
        if(sum <= B * Y) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
}
0