結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー |
![]() |
提出日時 | 2024-04-10 00:38:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 277 ms / 3,000 ms |
コード長 | 1,067 bytes |
コンパイル時間 | 2,381 ms |
コンパイル使用メモリ | 200,780 KB |
最終ジャッジ日時 | 2025-02-20 23:35:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h>using namespace std;void fast_io() {ios_base::sync_with_stdio(false);cin.tie(nullptr);}int n, a, b;long long x, y;bool check(vector<long long> &hh, long long H) {vector<long long> h(hh);int a_res = a;for (int i = 0; i < n; i++) {h[i] = max(0LL, h[i] - H);long long cnt = min((long long)a_res, h[i] / x);h[i] -= cnt * x;a_res -= cnt;}if (a_res >= n) {return true;}sort(h.rbegin(), h.rend());long long su = 0;for (int i = a_res; i < n; i++) {su += h[i];}if (su <= y * b) {return true;} else {return false;}}int main() {fast_io();cin >> n >> a >> b >> x >> y;vector<long long> h(n);for (int i = 0; i < n; i++) {cin >> h[i];}long long ng = -1, ok = 4e9;while (ok - ng > 1) {long long mid = (ok + ng) / 2;if (check(h, mid)) {ok = mid;} else {ng = mid;}}cout << ok << endl;}