結果

問題 No.1015 おつりは要らないです
ユーザー kagemeka
提出日時 2020-04-03 21:53:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,708 KB
最終ジャッジ日時 2024-07-03 02:20:53
合計ジャッジ時間 6,772 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r

n, x, y, z, *A = map(int, sys.stdin.read().split())

def main():
    A.sort(reverse=True)
    r = [x, y, z]
    cand = [1000, 5000, 10000]
    for a in A:
        for i in range(2, -1, -1):
            q, p = divmod(a, cand[i])
            if r[i] >= q:
                r[i] -= q
                q = 0
            else:
                q -= r[i]
                r[i] = 0
            a = q * cand[i] + p
        i = bi_r(cand, a)
        while i < 3:
            if r[i] > 0:
                r[i] -= 1
                break
            else:
                i += 1
        else:
            print('No')
            return
    print('Yes')

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