結果
| 問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-15 23:57:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 822 ms / 3,000 ms |
| コード長 | 1,202 bytes |
| コンパイル時間 | 1,908 ms |
| コンパイル使用メモリ | 172,728 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-15 08:48:38 |
| 合計ジャッジ時間 | 15,769 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#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;
}