結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー atreeatree
提出日時 2021-11-12 23:38:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,746 ms / 3,000 ms
コード長 1,336 bytes
コンパイル時間 2,898 ms
コンパイル使用メモリ 205,236 KB
実行使用メモリ 5,940 KB
最終ジャッジ日時 2023-08-17 04:29:03
合計ジャッジ時間 28,396 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 834 ms
5,788 KB
testcase_05 AC 1,101 ms
5,724 KB
testcase_06 AC 665 ms
5,576 KB
testcase_07 AC 10 ms
4,384 KB
testcase_08 AC 310 ms
4,632 KB
testcase_09 AC 465 ms
5,212 KB
testcase_10 AC 412 ms
4,384 KB
testcase_11 AC 626 ms
4,380 KB
testcase_12 AC 17 ms
4,380 KB
testcase_13 AC 1,022 ms
4,676 KB
testcase_14 AC 727 ms
5,172 KB
testcase_15 AC 711 ms
5,620 KB
testcase_16 AC 493 ms
4,384 KB
testcase_17 AC 345 ms
4,380 KB
testcase_18 AC 596 ms
4,380 KB
testcase_19 AC 178 ms
4,380 KB
testcase_20 AC 202 ms
4,380 KB
testcase_21 AC 434 ms
5,180 KB
testcase_22 AC 667 ms
5,504 KB
testcase_23 AC 832 ms
5,940 KB
testcase_24 AC 1,076 ms
5,792 KB
testcase_25 AC 1,052 ms
5,640 KB
testcase_26 AC 1,722 ms
5,628 KB
testcase_27 AC 1,084 ms
5,564 KB
testcase_28 AC 1,717 ms
5,564 KB
testcase_29 AC 1,089 ms
5,688 KB
testcase_30 AC 926 ms
5,692 KB
testcase_31 AC 1,729 ms
5,636 KB
testcase_32 AC 1,746 ms
5,696 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 3 ms
4,384 KB
testcase_36 AC 4 ms
4,380 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 2 ms
4,384 KB
testcase_39 AC 4 ms
4,380 KB
testcase_40 AC 2 ms
4,384 KB
testcase_41 AC 3 ms
4,380 KB
testcase_42 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define overload3(_NULL, _1, _2, name, ...) name
#define rep1(i, n) for (remove_const_t<remove_reference_t<decltype(n)>> i = 0; i < (n); i++)
#define rep2(i, a, b) for (remove_const_t<remove_reference_t<decltype(b)>> i = (a); i < (b); i++)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#if __has_include(<debug.hpp>)
#    include <debug.hpp>
#else
#    define dbg(...) (void(0))
#endif
using i64 = long long;
using usize = size_t;

int main() {
    usize n;
    cin >> n;
    i64 a, b, x, y;
    cin >> a >> b >> x >> y;
    vector<i64> h(n);
    for (auto &&hi: h) cin >> hi;

    auto check = [&](i64 k) {
        priority_queue<i64> que{};
        for (const auto &hi: h) que.push(max(hi - k, static_cast<i64>(0)));
        rep(i, a) {
            const auto t = que.top();
            que.pop();
            que.push(t - min(t, x));
        }
        i64 sum = 0;
        while (not empty(que)) {
            sum += que.top();
            que.pop();
        }
        return sum <= y * b;
    };

    i64 ok = numeric_limits<i64>::max() / 4, ng = numeric_limits<i64>::min() / 4;
    while (abs(ok - ng) > 1) {
        dbg(ok, ng);
        const auto mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << max(ok, static_cast<i64>(0)) << endl;
}
0