結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー titia
提出日時 2021-11-12 22:05:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,815 ms / 3,000 ms
コード長 450 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 108,216 KB
最終ジャッジ日時 2024-11-25 18:44:42
合計ジャッジ時間 32,595 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
import heapq

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

OK=max(H)
NG=-1

while OK>NG+1:
    mid=(OK+NG)//2
    Q=[]
    for h in H:
        h-=mid
        Q.append(min(0,-h))

    heapq.heapify(Q)

    for i in range(A):
        x=-heapq.heappop(Q)
        x=max(0,x-X)
        heapq.heappush(Q,-x)
    

    S=-sum(Q)
    if S<=Y*B:
        OK=mid
    else:
        NG=mid

print(OK)
0