結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー MasKoaTSMasKoaTS
提出日時 2021-11-12 22:29:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,475 bytes
コンパイル時間 4,853 ms
コンパイル使用メモリ 267,404 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-05-04 09:40:34
合計ジャッジ時間 40,761 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 32 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 163 ms
5,376 KB
testcase_07 AC 36 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 461 ms
5,376 KB
testcase_12 AC 45 ms
5,376 KB
testcase_13 AC 926 ms
6,784 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 453 ms
6,016 KB
testcase_20 AC 161 ms
5,376 KB
testcase_21 AC 1,028 ms
7,808 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1,785 ms
8,704 KB
testcase_27 WA -
testcase_28 AC 1,822 ms
8,960 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1,793 ms
8,704 KB
testcase_32 AC 1,779 ms
8,960 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 3 ms
5,376 KB
testcase_36 AC 4 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 4 ms
5,376 KB
testcase_39 AC 6 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 4 ms
5,376 KB
testcase_42 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	while (st.empty() == false) {
		auto it = st.begin();
		auto t = -(*it);
		st.erase(it);
		s += max(0, (ll)t);
	}
	if (s <= (ll)y * (ll)b) {
		return true;
	}
	return false;
}

int main(void) {
	ll n, a, b, x, y;	cin >> n >> a >> b >> x >> y;
	V<ll> h(n);
	rep(i, 0, n) {
		cin >> h[i];
	}

	ll ok = 1000000000;
	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;
}
0