結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー aaaaaaaaaa2230
提出日時 2021-11-12 21:55:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,848 ms / 3,000 ms
コード長 567 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 135,376 KB
最終ジャッジ日時 2024-11-25 18:15:57
合計ジャッジ時間 30,522 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush
n,a,b,x,y = map(int,input().split())
H = list(map(int,input().split()))

def calc(k):
    h = []
    for i in H:
        if i <= k:
            continue
        heappush(h,-i+k)

    for i in range(a):
        if h:
            num = -heappop(h)
            num -= x
            if num <= 0:
                continue
            heappush(h,-num)

    count = -sum(h)
    if count <= b*y:
        return 1
    return 0


l = -1
r = 10**10
while r > l+1:
    m = (r+l)//2
    if calc(m):
        r = m
    else:
        l = m
print(r)
0