結果

問題 No.1015 おつりは要らないです
ユーザー c-yan
提出日時 2020-04-03 23:12:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,796 KB
最終ジャッジ日時 2024-11-17 23:16:14
合計ジャッジ時間 8,997 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush

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

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

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

while A:
    if Y == 0:
        break
    x = -heappop(A)
    if x > 5000:
        t = min(x // 5000, Y)
        Y -= t
        x -= 5000 * t
        if x != 0:
            heappush(A, -x)
    else:
        Y -= 1

while A:
    if X == 0:
        break
    x = -heappop(A)
    t = min((x + 999) // 1000, X)
    X -= t
    x -= t * 1000
    if x > 0:
        heappush(A, -x)

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