結果

問題 No.1015 おつりは要らないです
ユーザー w0mbatw0mbat
提出日時 2020-11-03 22:00:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 92,156 KB
最終ジャッジ日時 2024-07-22 09:13:03
合計ジャッジ時間 7,806 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappush, heappop
import sys
def main():
    input = sys.stdin.readline
    N, X, Y, Z = map(int, input().split())
    *A, = map(lambda x: -int(x), input().split())
    heapify(A)
    cnt = [Z, Y, X]
    for c, n in enumerate([10000, 5000, 1000]):
        while A and cnt[c] > 0:
            p = -heappop(A)
            d = (p + 1) // n
            if d == 0:
                cnt[c] -= 1
                continue
            d = min(d, cnt[c])
            heappush(A, n * d - p)
            cnt[c] -= d
    print('No' if A else 'Yes')

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