結果

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

ソースコード

diff #

n,a,b,x,y = map(int,input().split())
H = list(map(lambda x:-int(x),input().split()))


import heapq
heapq.heapify(h)
# print(q)
def isok(mid):
    h = list(map(lambda x:min(0,x+mid),H))
    heapq.heapify(h)
    b_sum = b*y
#     print(h,mid)
    for i in range(a):
        aa = heapq.heappop(h)
        aa = min(aa+x,0)
        heapq.heappush(h,aa)
    h = list(map(lambda x:-int(x),h))
    # print(h)
    for i in range(n):
        d = min(b_sum,h[i])
        h[i] -= d
        b_sum -= d
    if sum(h) == 0:return True
    else:return False
l = -1
r = -min(H)
while r-l > 1:
    mid = (r+l) //2
    if isok(mid):
        r = mid
    else:
        l = mid
print(r)
0