結果
| 問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-12 22:26:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,688 ms / 3,000 ms |
| コード長 | 632 bytes |
| コンパイル時間 | 378 ms |
| コンパイル使用メモリ | 82,056 KB |
| 実行使用メモリ | 161,848 KB |
| 最終ジャッジ日時 | 2024-11-25 19:37:34 |
| 合計ジャッジ時間 | 30,140 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
from heapq import heappop,heappush
N,A,B,X,Y = map(int,input().split())
H = list(map(int,input().split()))
def is_ok(nH,nA):
q = []
for h in nH:
if h > 0:
heappush(q,-h)
while nA and q:
h = heappop(q)
h *= -1
if h > X:
heappush(q,-(h-X))
nA -=1
SUMS = 0
for h in q:
SUMS += -h
if SUMS <= Y * B:
return True
else:
return False
ok = 10 ** 9
ng = -1
while ok - ng > 1:
x = (ng+ok)//2
nH = []
for i in range(N):
nH.append(H[i]-x)
if is_ok(nH,A):
ok = x
else:
ng = x
print(ok)