結果
| 問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-12-22 18:48:38 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 987 bytes |
| コンパイル時間 | 3,969 ms |
| コンパイル使用メモリ | 142,028 KB |
| 実行使用メモリ | 5,856 KB |
| 最終ジャッジ日時 | 2024-09-16 13:46:24 |
| 合計ジャッジ時間 | 24,819 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 14 |
ソースコード
#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;
}
siman