結果

問題 No.1015 おつりは要らないです
ユーザー rlangevin
提出日時 2023-05-09 12:27:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 96,768 KB
最終ジャッジ日時 2024-11-25 23:44:31
合計ジャッジ時間 8,111 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

N, X, Y, Z = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x : -x, A))
heapify(A)
while Z and A:
    v = -heappop(A)
    if v >= 10000:
        n = min(Z, v // 10000)
        Z -= n
        v -= 10000 * n
        heappush(A, -v)
    else:
        Z -= 1

while Y and A:
    v = -heappop(A)
    if v >= 5000:
        n = min(Y, v // 5000)
        Y -= n
        v -= 5000 * n
        heappush(A, -v)
    else:
        Y -= 1

while X and A:
    v = -heappop(A)
    if v >= 1000:
        n = min(X, v // 1000)
        X -= n
        v -= 1000 * n
        heappush(A, -v)
    else:
        X -= 1

print("No") if A else print("Yes")
0