結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-11-13 16:10:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,823 ms / 3,000 ms
コード長 377 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 102,536 KB
最終ジャッジ日時 2024-11-27 12:58:07
合計ジャッジ時間 32,844 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

n, a, b, x, y = map(int, input().split())
h = list(map(int, input().split()))
def ok(X):
	h2 = [min(0, X - h[i]) for i in range(n)]
	heapify(h2)
	for i in range(a):
		ma = min(0, heappop(h2) + x)
		heappush(h2, ma)
	return True if sum(h2) * -1 <= b * y else False
l, r = -1, 10 ** 9
while r - l > 1:
	m = (l + r) // 2
	if ok(m): r = m
	else: l = m
print(r)
0