結果

問題 No.1015 おつりは要らないです
ユーザー c-yan
提出日時 2020-04-05 03:55:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,692 KB
最終ジャッジ日時 2024-07-03 07:58:52
合計ジャッジ時間 10,177 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush

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

amounts = [Z, Y, X]
bills = [10000, 5000, 1000]

A = [-a for a in A]
heapify(A)

for i in range(3):
    a = amounts[i]
    b = bills[i]

    while A:
        if a == 0:
            break
        x = -heappop(A)
        if x >= b:
            t = min(x // b, Z)
            a -= t
            x -= 10000 * b
            heappush(A, -x)
        else:
            a -= 1

if len(A) == 0:
    print('Yes')
else:
    print('No')
0