結果

問題 No.1015 おつりは要らないです
ユーザー maspymaspy
提出日時 2020-03-16 12:41:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,708 KB
最終ジャッジ日時 2024-05-06 01:03:14
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 26 ms
10,624 KB
testcase_08 AC 25 ms
10,752 KB
testcase_09 AC 24 ms
10,624 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 53 ms
20,952 KB
testcase_16 AC 56 ms
21,000 KB
testcase_17 AC 54 ms
21,328 KB
testcase_18 AC 54 ms
21,216 KB
testcase_19 AC 55 ms
20,908 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 30 ms
10,496 KB
testcase_31 AC 176 ms
12,752 KB
testcase_32 AC 171 ms
12,648 KB
testcase_33 AC 60 ms
21,580 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 27 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/local/bin/python3.8
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def min_pay(a, X, Y, Z):
    x, y, z = 0, 0, 0
    z = min(Z, a // 10000)
    a -= 10000 * z
    y = min(Y, a // 5000)
    a -= 5000 * z
    x = min(X, a // 1000)
    a -= 1000 * x
    if x < X:
        x += 1
    elif y < Y:
        y += 1
    elif z < Z:
        z += 1
    return x, y, z


def solve(A, X, Y, Z):
    """左から順に、その都度の支払い額を最小にしていく"""
    A = (x + 1 for x in A)
    for a in A:
        x, y, z = min_pay(a, X, Y, Z)
        if 1000 * x + 5000 * y + 10000 * z < a:
            return False
        X -= x
        Y -= y
        Z -= z
    return True


N, X, Y, Z, *A = map(int, read().split())
print('Yes' if solve(A, X, Y, Z) else 'No')
0