結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー brthyyjp
提出日時 2021-11-14 02:02:21
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 859 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,840 KB
実行使用メモリ 124,628 KB
最終ジャッジ日時 2024-11-28 15:45:50
合計ジャッジ時間 46,570 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():

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

    def is_ok(k):
        q = []
        for h in H:
            if h > k:
                q.append(-(h-k))
        if not q:
            return True
        heapq.heapify(q)
        for i in range(a):
            if q:
                v = heapq.heappop(q)
                v = -v
                if v > x:
                    v -= x
                    heapq.heappush(q, -v)
        if not q:
            return True
        s = 0
        while  q:
            v = heapq.heappop(q)
            v = -v
            s += v
        return  s <= y*b

    ng = -1
    ok = max(H)
    while ng+1<ok:
        c = (ng+ok)//2
        if is_ok(c):
            ok = c
        else:
            ng = c
    print(ok)

if __name__ == '__main__':
    main()
0