結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー granddaifukugranddaifuku
提出日時 2021-11-15 23:57:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 811 ms / 3,000 ms
コード長 1,202 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 171,804 KB
実行使用メモリ 5,856 KB
最終ジャッジ日時 2023-08-21 18:54:15
合計ジャッジ時間 15,260 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 505 ms
5,536 KB
testcase_05 AC 811 ms
5,628 KB
testcase_06 AC 128 ms
5,636 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 220 ms
4,444 KB
testcase_09 AC 269 ms
4,796 KB
testcase_10 AC 235 ms
4,380 KB
testcase_11 AC 137 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 299 ms
4,620 KB
testcase_14 AC 526 ms
5,224 KB
testcase_15 AC 449 ms
5,432 KB
testcase_16 AC 353 ms
4,380 KB
testcase_17 AC 217 ms
4,384 KB
testcase_18 AC 391 ms
4,384 KB
testcase_19 AC 47 ms
4,380 KB
testcase_20 AC 92 ms
4,380 KB
testcase_21 AC 197 ms
4,640 KB
testcase_22 AC 427 ms
5,360 KB
testcase_23 AC 462 ms
5,548 KB
testcase_24 AC 782 ms
5,712 KB
testcase_25 AC 717 ms
5,428 KB
testcase_26 AC 513 ms
5,712 KB
testcase_27 AC 774 ms
5,856 KB
testcase_28 AC 528 ms
5,572 KB
testcase_29 AC 779 ms
5,628 KB
testcase_30 AC 557 ms
5,432 KB
testcase_31 AC 578 ms
5,696 KB
testcase_32 AC 786 ms
5,640 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

__attribute__((unused)) const ll INF = 1e18;
__attribute__((unused)) const int Inf = 1e9;
__attribute__((unused)) const double EPS = 1e-9;
__attribute__((unused)) const ll MOD = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  int n, a, b;
  ll x, y;
  cin >> n >> a >> b >> x >> y;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  int left = -1, right = Inf, mid;
  while (right - left > 1) {
    mid = (left + right) / 2;
    priority_queue<ll> pq;
    rep(i, n) {
      ll tmp = h[i] - mid;
      if (tmp <= 0) continue;
      pq.push(tmp);
    }
    rep(i, a) {
      if (pq.size() == 0) break;
      ll t = pq.top();
      pq.pop();
      t -= x;
      if (t <= 0) continue;
      pq.push(t);
    }
    ll lim = y * b;
    while (!pq.empty()) {
      ll t = pq.top();
      pq.pop();
      lim -= t;
    }
    if (lim >= 0)
      right = mid;
    else
      left = mid;
  }
  cout << right << endl;

  return 0;
}
0