結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー kabipoyokabipoyo
提出日時 2021-11-15 17:09:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 840 ms / 3,000 ms
コード長 1,424 bytes
コンパイル時間 4,159 ms
コンパイル使用メモリ 263,916 KB
実行使用メモリ 5,972 KB
最終ジャッジ日時 2023-08-21 11:43:08
合計ジャッジ時間 19,700 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 524 ms
5,416 KB
testcase_05 AC 840 ms
5,672 KB
testcase_06 AC 158 ms
5,696 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 236 ms
4,560 KB
testcase_09 AC 284 ms
5,248 KB
testcase_10 AC 245 ms
4,376 KB
testcase_11 AC 150 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 324 ms
4,588 KB
testcase_14 AC 540 ms
5,288 KB
testcase_15 AC 469 ms
5,492 KB
testcase_16 AC 362 ms
4,376 KB
testcase_17 AC 229 ms
4,376 KB
testcase_18 AC 407 ms
4,380 KB
testcase_19 AC 60 ms
4,376 KB
testcase_20 AC 101 ms
4,376 KB
testcase_21 AC 216 ms
4,764 KB
testcase_22 AC 444 ms
5,460 KB
testcase_23 AC 481 ms
5,668 KB
testcase_24 AC 804 ms
5,680 KB
testcase_25 AC 742 ms
5,364 KB
testcase_26 AC 554 ms
5,624 KB
testcase_27 AC 793 ms
5,972 KB
testcase_28 AC 564 ms
5,680 KB
testcase_29 AC 799 ms
5,684 KB
testcase_30 AC 578 ms
5,568 KB
testcase_31 AC 616 ms
5,620 KB
testcase_32 AC 833 ms
5,844 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
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; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint N, A, B, X, Y;
	cin >> N >> A >> B >> X >> Y;
	vi v(N);
	vin(v);

	lint a=0, b=0, c=0, x, y, z;
	lint ng = -1, mid, ok = LINF;
	while (abs(ok - ng) > 1) {
		mid = (ok + ng) / 2;
		priority_queue<lint> q;
		rep(i, N) {
			if (v[i]-mid > 0) q.push(v[i]-mid);
		}

		rep(i, A) {
			if (q.empty()) break;
			x = q.top();
			q.pop();
			x -= X;
			if (x > 0) q.push(x);
		}
		a = 0;
		while (!q.empty()) {
			a += q.top();
			q.pop();
		}
		if (a <= B*Y) ok = mid;
		else ng = mid;
	}
	std::cout << ok << '\n';
}
0