結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー first_vil
提出日時 2021-11-12 22:31:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 527 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,704 KB
実行使用メモリ 126,480 KB
最終ジャッジ日時 2024-11-25 19:50:14
合計ジャッジ時間 61,617 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def solve(k):
    a = A
    h = list(map(lambda x: (x-k)*-1,H))
    heapify(h)
    while a:
        v = heappop(h)*-1
        if v <= 0:
            break
        heappush(h,(v-x)*-1)
        a -= 1
    s = 0
    while h:
        s += max(0, heappop(h)*-1)
    return s <= y*b

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