結果

問題 No.1015 おつりは要らないです
ユーザー shikixyxshikixyx
提出日時 2020-04-03 22:04:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,335 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 18,908 KB
最終ジャッジ日時 2023-09-16 01:45:28
合計ジャッジ時間 4,506 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,148 KB
testcase_01 AC 15 ms
8,224 KB
testcase_02 AC 15 ms
8,140 KB
testcase_03 AC 16 ms
8,140 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 16 ms
8,264 KB
testcase_08 AC 16 ms
8,260 KB
testcase_09 AC 15 ms
8,128 KB
testcase_10 AC 121 ms
18,556 KB
testcase_11 AC 125 ms
18,740 KB
testcase_12 AC 119 ms
18,076 KB
testcase_13 AC 120 ms
18,592 KB
testcase_14 AC 127 ms
18,908 KB
testcase_15 AC 117 ms
18,280 KB
testcase_16 AC 118 ms
18,636 KB
testcase_17 AC 127 ms
18,836 KB
testcase_18 AC 120 ms
18,528 KB
testcase_19 AC 123 ms
18,584 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 15 ms
8,084 KB
testcase_31 WA -
testcase_32 AC 71 ms
10,052 KB
testcase_33 AC 58 ms
18,880 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 16 ms
8,208 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 = [-(-a // 1000) for a in A]


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)
        Y -= y
        a -= y * 5000

    ok = True
    if a > 0:
        ok = False
    elif a < 0:
        pass
    elif 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