結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー simansiman
提出日時 2021-12-22 18:50:00
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 1,242 ms / 3,000 ms
コード長 1,001 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 106,532 KB
実行使用メモリ 5,824 KB
最終ジャッジ日時 2023-10-14 19:53:44
合計ジャッジ時間 19,145 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1,102 ms
5,756 KB
testcase_05 AC 1,242 ms
5,732 KB
testcase_06 AC 54 ms
4,976 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 322 ms
4,600 KB
testcase_09 AC 469 ms
5,356 KB
testcase_10 AC 580 ms
4,348 KB
testcase_11 AC 24 ms
4,356 KB
testcase_12 AC 15 ms
4,348 KB
testcase_13 AC 44 ms
4,352 KB
testcase_14 AC 812 ms
5,304 KB
testcase_15 AC 891 ms
5,756 KB
testcase_16 AC 636 ms
4,348 KB
testcase_17 AC 463 ms
4,368 KB
testcase_18 AC 701 ms
4,352 KB
testcase_19 AC 258 ms
4,356 KB
testcase_20 AC 14 ms
4,372 KB
testcase_21 AC 586 ms
5,276 KB
testcase_22 AC 833 ms
5,644 KB
testcase_23 AC 1,211 ms
5,712 KB
testcase_24 AC 1,212 ms
5,824 KB
testcase_25 AC 1,162 ms
5,712 KB
testcase_26 AC 70 ms
4,952 KB
testcase_27 AC 1,195 ms
5,748 KB
testcase_28 AC 70 ms
5,028 KB
testcase_29 AC 1,216 ms
5,676 KB
testcase_30 AC 1,197 ms
5,756 KB
testcase_31 AC 70 ms
4,956 KB
testcase_32 AC 71 ms
4,952 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 1 ms
4,356 KB
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 2 ms
4,352 KB
testcase_38 AC 3 ms
4,352 KB
testcase_39 AC 4 ms
4,352 KB
testcase_40 AC 2 ms
4,356 KB
testcase_41 AC 3 ms
4,352 KB
testcase_42 AC 2 ms
4,372 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;
    return 0;
  }

  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