結果

問題 No.1739 Princess vs. Dragoness (& AoE)
コンテスト
ユーザー Shirotsume
提出日時 2021-10-28 23:33:10
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 652 ms / 3,000 ms
+ 556µs
コード長 755 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 81 ms
コンパイル使用メモリ 65,140 KB
実行使用メモリ 91,200 KB
最終ジャッジ日時 2026-10-20 02:36:18
合計ジャッジ時間 17,429 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, a, b, x, y = map(int,input().split())
h = list(map(int,input().split()))
def solve(n, a, b, x, y, h):
    h.sort()
    from collections import deque
    def check(k):
        import heapq
        h2 = [0] * n
        for i in range(n):
            h2[i] = min(0, k - h[i])
        heapq.heapify(h2)       
        
        for i in range(a):
            now = heapq.heappop(h2)
            now = min(0, now + x)
            heapq.heappush(h2, now)
        if -sum(h2) <= b * y:
            return True
        else:
            return False

    ok = 10 ** 9
    ng = -1

    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    return ok
print(solve(n, a, b, x, y, h))
0