結果

問題 No.1739 Princess vs. Dragoness (& AoE)
コンテスト
ユーザー ntuda
提出日時 2025-06-07 16:44:12
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 962 ms / 3,000 ms
+ 97µs
コード長 474 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 93 ms
コンパイル使用メモリ 64,544 KB
実行使用メモリ 96,452 KB
最終ジャッジ日時 2026-10-29 02:35:16
合計ジャッジ時間 20,427 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

def check(x):
    Q = []
    for h in H:
        if h - x > 0:
            heappush(Q,x - h)
    for _ in range(A):
        if Q:
            a = heappop(Q)
            if a + X < 0:
                heappush(Q,a+X)
    return -sum(Q) <= B * Y

lb = -1
ub = 10 ** 9
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        ub = mid
    else:
        lb = mid
print(ub)
0