結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー simansiman
提出日時 2021-12-22 18:48:38
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 106,304 KB
実行使用メモリ 5,824 KB
最終ジャッジ日時 2023-10-14 19:52:10
合計ジャッジ時間 29,390 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 WA -
testcase_04 AC 1,114 ms
5,752 KB
testcase_05 AC 1,259 ms
5,720 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 325 ms
4,584 KB
testcase_09 AC 482 ms
5,424 KB
testcase_10 AC 589 ms
4,372 KB
testcase_11 WA -
testcase_12 AC 15 ms
4,372 KB
testcase_13 WA -
testcase_14 AC 832 ms
5,232 KB
testcase_15 AC 910 ms
5,780 KB
testcase_16 AC 643 ms
4,372 KB
testcase_17 AC 469 ms
4,368 KB
testcase_18 AC 708 ms
4,368 KB
testcase_19 AC 255 ms
4,372 KB
testcase_20 WA -
testcase_21 AC 596 ms
5,268 KB
testcase_22 AC 847 ms
5,636 KB
testcase_23 AC 1,229 ms
5,772 KB
testcase_24 AC 1,240 ms
5,764 KB
testcase_25 AC 1,182 ms
5,668 KB
testcase_26 WA -
testcase_27 AC 1,210 ms
5,716 KB
testcase_28 WA -
testcase_29 AC 1,237 ms
5,660 KB
testcase_30 AC 1,222 ms
5,752 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,372 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 3 ms
4,368 KB
testcase_39 AC 4 ms
4,372 KB
testcase_40 AC 2 ms
4,368 KB
testcase_41 AC 3 ms
4,372 KB
testcase_42 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

ll N, A, B, X, Y;
vector<ll> H;

bool f(ll k = 0) {
  priority_queue <ll> pque;

  for (int i = 0; i < N; ++i) {
    pque.push(max(0LL, H[i] - k));
  }

  for (int i = 0; i < A; ++i) {
    ll h = pque.top();
    pque.pop();
    pque.push(h - X);
  }

  ll sum = 0;
  while (not pque.empty()) {
    ll h = pque.top();
    pque.pop();
    sum += max(0LL, h);
  }

  return (sum <= B * Y);
}

int main() {
  cin >> N >> A >> B >> X >> Y;
  H.resize(N);

  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  if (f()) {
    cout << 0 << endl;
  }

  ll ng = 0;
  ll ok = LLONG_MAX;
  while (abs(ok - ng) >= 2) {
    ll k = (ok + ng) / 2;

    if (f(k)) {
      ok = k;
    } else {
      ng = k;
    }
  }

  cout << ok << endl;

  return 0;
}

0