結果

問題 No.1739 Princess vs. Dragoness (& AoE)
コンテスト
ユーザー kaeru82433413
提出日時 2021-11-12 21:48:04
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 985 ms / 3,000 ms
+ 591µs
コード長 512 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 78 ms
コンパイル使用メモリ 64,968 KB
実行使用メモリ 92,020 KB
最終ジャッジ日時 2026-10-20 02:50:52
合計ジャッジ時間 23,045 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from heapq import heappop as pop, heappush as push, heapify

N, A, B, X, Y = map(int, input().split())
H = list(map(int, input().split()))

def solve(k):
    hh = list(map(lambda x: -(x-k), H))
    heapify(hh)
    for _ in range(A):
        h = -pop(hh)
        h -= X
        push(hh, -h)
    remain = 0
    for h in hh:
        remain += max(0, -h)
    return remain <= Y*B

ok, ng = max(H), -1
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0