結果

問題 No.1736 Princess vs. Dragoness
コンテスト
ユーザー bayashi-cl
提出日時 2021-11-12 22:09:42
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 28 ms / 2,000 ms
+ 38µs
コード長 625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,720 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2026-10-15 03:25:21
合計ジャッジ時間 3,043 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq
from operator import itemgetter


def main() -> None:
    n, a, b, x, y = map(int, input().split())
    rem_b = y * b
    h = list(map(int, input().split()))
    que = [(-h[i], i) for i in range(n)]
    heapq.heapify(que)
    for _ in range(a):
        top, i = heapq.heappop(que)
        top += x
        heapq.heappush(que, (top, i))

    que.sort(key=itemgetter(1))

    for hi, _ in que:
        hi *= -1

        if hi >= 0:
            if hi > rem_b:
                print("No")
                return
            else:
                rem_b -= hi

    print("Yes")


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