結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー | milanis48663220 |
提出日時 | 2021-11-12 22:17:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 724 ms / 3,000 ms |
コード長 | 2,344 bytes |
コンパイル時間 | 1,239 ms |
コンパイル使用メモリ | 123,244 KB |
実行使用メモリ | 8,520 KB |
最終ジャッジ日時 | 2023-08-17 02:00:22 |
合計ジャッジ時間 | 12,701 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,384 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 569 ms
8,372 KB |
testcase_05 | AC | 680 ms
8,352 KB |
testcase_06 | AC | 32 ms
6,800 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 84 ms
5,764 KB |
testcase_09 | AC | 144 ms
7,900 KB |
testcase_10 | AC | 360 ms
5,140 KB |
testcase_11 | AC | 12 ms
4,376 KB |
testcase_12 | AC | 14 ms
4,384 KB |
testcase_13 | AC | 21 ms
4,992 KB |
testcase_14 | AC | 418 ms
7,296 KB |
testcase_15 | AC | 380 ms
8,436 KB |
testcase_16 | AC | 381 ms
4,472 KB |
testcase_17 | AC | 199 ms
5,568 KB |
testcase_18 | AC | 437 ms
5,688 KB |
testcase_19 | AC | 108 ms
5,708 KB |
testcase_20 | AC | 6 ms
4,384 KB |
testcase_21 | AC | 235 ms
7,744 KB |
testcase_22 | AC | 378 ms
8,168 KB |
testcase_23 | AC | 628 ms
8,520 KB |
testcase_24 | AC | 656 ms
8,352 KB |
testcase_25 | AC | 667 ms
8,520 KB |
testcase_26 | AC | 34 ms
6,908 KB |
testcase_27 | AC | 710 ms
8,512 KB |
testcase_28 | AC | 35 ms
6,756 KB |
testcase_29 | AC | 724 ms
8,412 KB |
testcase_30 | AC | 678 ms
8,252 KB |
testcase_31 | AC | 37 ms
6,692 KB |
testcase_32 | AC | 35 ms
6,644 KB |
testcase_33 | AC | 1 ms
4,380 KB |
testcase_34 | AC | 2 ms
4,380 KB |
testcase_35 | AC | 1 ms
4,376 KB |
testcase_36 | AC | 2 ms
4,380 KB |
testcase_37 | AC | 1 ms
4,380 KB |
testcase_38 | AC | 2 ms
4,380 KB |
testcase_39 | AC | 2 ms
4,376 KB |
testcase_40 | AC | 2 ms
4,380 KB |
testcase_41 | AC | 2 ms
4,376 KB |
testcase_42 | AC | 2 ms
4,380 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template<typename T> vector<vector<T>> vec2d(int n, int m, T v){ return vector<vector<T>>(n, vector<T>(m, v)); } template<typename T> vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){ return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v))); } template<typename T> void print_vector(vector<T> v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using P = pair<ll, int>; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n; cin >> n; ll a, b, x, y; cin >> a >> b >> x >> y; vector<ll> w(n); for(int i = 0; i < n; i++) { cin >> w[i]; } auto ok = [&](ll p, int a){ vector<ll> h(n); priority_queue<P> que; for(int i = 0; i < n; i++){ h[i] = max(0ll, w[i]-p); } for(int i = 0; i < n; i++) { que.push(P(h[i], i)); } while(a > 0 && !que.empty()){ auto [_, i] = que.top(); que.pop(); a--; h[i] -= x; if(h[i] <= 0) continue; que.push(P(h[i], i)); } for(int i = 0; i < n; i++){ if(h[i] <= 0) h[i] = 0; } ll sum = accumulate(h.begin(), h.end(), 0ll); return sum <= y*b; }; if(ok(0, a)){ cout << 0 << endl; return 0; } ll h_max = *max_element(w.begin(), w.end()); ll l = 0, r = h_max; while(r-l > 1){ ll x = (l+r)/2; if(ok(x, a)) r = x; else l = x; } cout << r << endl; }