結果

問題 No.1015 おつりは要らないです
ユーザー shikixyxshikixyx
提出日時 2020-04-03 22:20:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,531 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 19,016 KB
最終ジャッジ日時 2023-09-16 02:34:12
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,340 KB
testcase_01 AC 18 ms
8,204 KB
testcase_02 AC 18 ms
8,308 KB
testcase_03 AC 17 ms
8,284 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 16 ms
8,160 KB
testcase_08 AC 16 ms
8,228 KB
testcase_09 AC 16 ms
8,308 KB
testcase_10 AC 160 ms
18,744 KB
testcase_11 AC 163 ms
18,824 KB
testcase_12 AC 152 ms
18,160 KB
testcase_13 AC 159 ms
18,612 KB
testcase_14 AC 166 ms
18,944 KB
testcase_15 AC 155 ms
18,284 KB
testcase_16 AC 160 ms
18,644 KB
testcase_17 AC 165 ms
18,848 KB
testcase_18 AC 155 ms
18,720 KB
testcase_19 AC 156 ms
18,640 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 16 ms
8,212 KB
testcase_31 AC 93 ms
10,104 KB
testcase_32 AC 95 ms
10,116 KB
testcase_33 AC 61 ms
19,016 KB
testcase_34 WA -
testcase_35 AC 16 ms
8,204 KB
testcase_36 AC 17 ms
8,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A.sort(reverse=True)


def pay(a, X, Y, Z):
    # 1万円札はあるだけ
    if a >= 10000:
        z = a // 10000

        if Z >= z:
            Z -= z
            a -= z * 10000
        else:
            a -= Z * 10000
            Z = 0

    # 1万円札未満
    # 5千円以上かつ、5千円札あり
    if a >= 5000:
        y = a // 5000

        if Y >= y:
            a -= 5000 * y
            Y -= y
        else:
            a -= 5000 * Y
            Y = 0

    # 千円札で端数まで払う
    if a > 0:
        x = -(-a // 1000)

        if X >= x:
            X -= x
            a -= x * 1000

    # 払い切れてない時
    # 5千円札あり
    if a > 0 and Y > 0:
        y = -(-a // 5000)

        if Y >= y:
            Y -= y
            a -= y * 5000

    # 一万円札あり
    if a > 0 and Z > 0:
        z = -(-a // 10000)
        if Z >= z:
            Z -= z
            a -= z * 10000

    ok = True
    if a > 0:
        ok = False
    elif a == 0:
        if 0 < X:
            X -= 1
        elif 0 < Y:
            Y -= 1
        elif 0 < Z:
            Z -= 1
        else:
            ok = False

    return ok, X, Y, Z


for a in A:
    ok, X, Y, Z = pay(a, X, Y, Z)
    if ok:
        continue
    else:
        print('No')
        exit()

print('Yes')
0