結果
問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
ユーザー |
![]() |
提出日時 | 2021-11-12 22:54:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,456 bytes |
コンパイル時間 | 3,572 ms |
コンパイル使用メモリ | 254,692 KB |
最終ジャッジ日時 | 2025-01-25 17:21:47 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 17 |
ソースコード
#include <math.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, l, n) for (int i = (l); i < (n); i++) #define max(p, q) ((p) > (q) ? (p) : (q)) #define min(p, q) ((p) < (q) ? (p) : (q)) #define all(x) x.begin(), x.end() #define fi first #define se second #define lb lower_bound; #define ub upper_bound; //#define lb(A, x) (ll)(lower_bound(all(A), x) - A.begin()) //#define ub(A, x) (ll)(upper_bound(all(A), x) - A.begin()) using ll = long long; using P = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V<V<T> >; template <class T> const ll INF = 1000000000000000001; const int inf = 1001001001; const ll mod = 1000000007; const ll MOD = 998244353; bool func(V<ll>&h,ll n,ll a,ll b,ll x,ll y,ll k) { set<ll> st{}; rep(i, 0, n) { st.insert(-h[i] + k); } rep(i, 0, a) { auto it = st.begin(); ll t = *it + x; //cout << *it << endl; st.erase(it); st.insert(t); } ll s = 0; for (auto it = st.begin(); it != st.end(); it++) { s += max(0, -(*it)); } if (s <= y * b) { return true; } return false; } int main(void) { ll n, a, b, x, y; cin >> n >> a >> b >> x >> y; ll mh = 0; V<ll> h(n); rep(i, 0, n) { cin >> h[i]; mh = max(mh, h[i]); } ll ok = mh; ll ng = -1; while (ok - ng > 1) { ll k = (ok + ng) / 2; if (func(h, n, a, b, x, y, k)) { ok = k; } else { ng = k; } } cout << ok << endl; return 0; }