結果

問題 No.1015 おつりは要らないです
ユーザー w0mbatw0mbat
提出日時 2020-11-03 22:10:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 92,148 KB
最終ジャッジ日時 2024-11-18 07:26:39
合計ジャッジ時間 7,154 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

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, m = divmod(p + 1, n)
            if d == 0 or (d == 1 and m == 0):
                cnt[c] -= 1
                continue
            if m == 0: d -= 1
            d = min(d, cnt[c])
            heappush(A, n * d - p)
            cnt[c] -= d
    print('No' if A else 'Yes')

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