結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー Hydru
提出日時 2021-11-12 22:27:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 3,000 ms
コード長 542 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 110,680 KB
最終ジャッジ日時 2024-11-25 19:38:59
合計ジャッジ時間 5,931 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

N,A,B,X,Y=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
l=-1
r=max(H)
while(r-l>1):
    mid=(r+l)//2
    Z=[max(x-mid,0) for x in H]
    cnt=A
    for i in range(N):
        if Z[i]>=X:
            if cnt>Z[i]//X:
                cnt-=Z[i]//X
                Z[i]%=X
            else:
                Z[i]-=cnt*X
                cnt=0
                break
    if cnt>0:
        Z.sort(reverse=True)
        for i in range(min(N,cnt)):
            Z[i]=0
    if sum(Z)<=B*Y:
        r=mid
    else:
        l=mid
print(r)
0