結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー kwm_tkwm_t
提出日時 2021-11-12 21:48:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 720 ms / 3,000 ms
コード長 1,530 bytes
コンパイル時間 1,781 ms
コンパイル使用メモリ 171,916 KB
実行使用メモリ 6,004 KB
最終ジャッジ日時 2024-05-04 08:11:36
合計ジャッジ時間 13,140 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_04 AC 441 ms
5,748 KB
testcase_05 AC 720 ms
5,880 KB
testcase_06 AC 116 ms
5,872 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 193 ms
5,376 KB
testcase_09 AC 236 ms
5,376 KB
testcase_10 AC 214 ms
5,376 KB
testcase_11 AC 123 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 264 ms
5,376 KB
testcase_14 AC 475 ms
5,412 KB
testcase_15 AC 391 ms
5,740 KB
testcase_16 AC 323 ms
5,376 KB
testcase_17 AC 191 ms
5,376 KB
testcase_18 AC 347 ms
5,376 KB
testcase_19 AC 40 ms
5,376 KB
testcase_20 AC 79 ms
5,376 KB
testcase_21 AC 181 ms
5,376 KB
testcase_22 AC 372 ms
5,404 KB
testcase_23 AC 418 ms
5,688 KB
testcase_24 AC 689 ms
5,620 KB
testcase_25 AC 633 ms
5,620 KB
testcase_26 AC 449 ms
5,872 KB
testcase_27 AC 682 ms
5,612 KB
testcase_28 AC 461 ms
6,004 KB
testcase_29 AC 686 ms
5,744 KB
testcase_30 AC 486 ms
5,748 KB
testcase_31 AC 505 ms
5,872 KB
testcase_32 AC 691 ms
5,876 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
vector<long long>h;
long long n, a, b;
long long x, y;
bool f(int c) {
	priority_queue<long long>pq;
	rep(i, h.size())if (h[i] - c > 0)pq.push(h[i] - c);
	rep(i, a) {
		if (pq.empty())break;
		long long top = pq.top();
		pq.pop();
		top -= x;
		if (top > 0)pq.push(top);
	}
	long long sum = 0;
	while (!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	return sum <= y * b;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> a >> b;
	cin >> x >> y;
	h.resize(n);
	rep(i, n) cin >> h[i];
	int ng = -1;
	int ok = INF + 1;
	while (1 < abs(ok - ng)) {
		int c = (ng + ok) / 2;
		if (f(c)) ok = c;
		else ng = c;
	}
	cout << ok << endl;
	return 0;
}
0