結果
| 問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
| コンテスト | |
| ユーザー |
nok0
|
| 提出日時 | 2021-11-01 15:31:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 920 ms / 3,000 ms |
| コード長 | 661 bytes |
| コンパイル時間 | 2,646 ms |
| コンパイル使用メモリ | 196,948 KB |
| 最終ジャッジ日時 | 2025-01-25 10:17:52 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#define __GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x) for(int i = 0; i < (x); i++)
int main() {
int n, a, b, x, y;
cin >> n >> a >> b >> x >> y;
vector h(n, 0);
for(auto &v : h) cin >> v;
auto f = [&](int k) {
priority_queue<int> pq;
for(auto &v : h) pq.push(v - k);
rep(i, a) {
if(pq.top() <= 0) break;
pq.push(pq.top() - x);
pq.pop();
}
long long sum = 0;
while(!pq.empty()) {
sum += max(pq.top(), 0);
pq.pop();
}
return sum <= (long long)y * b;
};
int ok = 1000000000, ng = -1;
while(ok - ng > 1) {
int mid = (ok + ng) >> 1;
(f(mid) ? ok : ng) = mid;
}
cout << ok << '\n';
}
nok0