結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー | norikame |
提出日時 | 2021-11-13 17:41:59 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 459 ms / 3,000 ms |
コード長 | 1,395 bytes |
コンパイル時間 | 2,139 ms |
コンパイル使用メモリ | 206,544 KB |
実行使用メモリ | 5,792 KB |
最終ジャッジ日時 | 2023-08-18 11:18:44 |
合計ジャッジ時間 | 12,837 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,384 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 367 ms
5,372 KB |
testcase_05 | AC | 418 ms
5,624 KB |
testcase_06 | AC | 331 ms
5,684 KB |
testcase_07 | AC | 2 ms
4,384 KB |
testcase_08 | AC | 77 ms
4,444 KB |
testcase_09 | AC | 103 ms
4,780 KB |
testcase_10 | AC | 206 ms
4,380 KB |
testcase_11 | AC | 139 ms
4,380 KB |
testcase_12 | AC | 4 ms
4,380 KB |
testcase_13 | AC | 270 ms
4,576 KB |
testcase_14 | AC | 266 ms
5,280 KB |
testcase_15 | AC | 283 ms
5,464 KB |
testcase_16 | AC | 240 ms
4,384 KB |
testcase_17 | AC | 151 ms
4,380 KB |
testcase_18 | AC | 228 ms
4,384 KB |
testcase_19 | AC | 55 ms
4,384 KB |
testcase_20 | AC | 42 ms
4,384 KB |
testcase_21 | AC | 140 ms
4,584 KB |
testcase_22 | AC | 268 ms
5,404 KB |
testcase_23 | AC | 450 ms
5,792 KB |
testcase_24 | AC | 432 ms
5,684 KB |
testcase_25 | AC | 408 ms
5,660 KB |
testcase_26 | AC | 459 ms
5,584 KB |
testcase_27 | AC | 385 ms
5,668 KB |
testcase_28 | AC | 450 ms
5,580 KB |
testcase_29 | AC | 410 ms
5,620 KB |
testcase_30 | AC | 444 ms
5,304 KB |
testcase_31 | AC | 431 ms
5,636 KB |
testcase_32 | AC | 391 ms
5,616 KB |
testcase_33 | AC | 2 ms
4,380 KB |
testcase_34 | AC | 1 ms
4,380 KB |
testcase_35 | AC | 2 ms
4,384 KB |
testcase_36 | AC | 1 ms
4,380 KB |
testcase_37 | AC | 1 ms
4,384 KB |
testcase_38 | AC | 2 ms
4,380 KB |
testcase_39 | AC | 2 ms
4,380 KB |
testcase_40 | AC | 1 ms
4,380 KB |
testcase_41 | AC | 2 ms
4,384 KB |
testcase_42 | AC | 1 ms
4,384 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i=0; i<(int)(n); ++(i)) #define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i)) #define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i)) #define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i)) #define all(x) (x).begin(), (x).end() int main() { int n, a, b, x, y; cin >> n >> a >> b >> x >> y; vector<int> h(n); rep(i, n) cin >> h[i]; int mval = 0; rep(i, n) mval = max(mval, h[i]); int l = 0, r = mval; while (r-l > 0) { int c = l + (r-l) / 2; auto th = h; rep(i, n) th[i] -= min(th[i], c); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> mh; rep(i, n) if (th[i] > 0) mh.emplace(max(0, x-th[i]), i); bool res = (mh.empty()); if (!res) { rep(i, a) { auto pi = mh.top(); mh.pop(); th[pi.second] -= min(th[pi.second], x); if (th[pi.second] > 0) mh.emplace(max(0, x-th[pi.second]), pi.second); if (mh.empty()) { res = true; break; } } } if (!res) { int id = 0; rep(i, b) { int p = y; while (p>0 && id<n) { int d = min(p, th[id]); th[id] -= d; p -= d; if (th[id] <= 0) ++id; } while (id<n && th[id]==0) ++id; if (id >= n) { res = true; break; } } } if (res) r = c; else l = c+1; } cout << min(l, r) << endl; return 0; }