結果

問題 No.1015 おつりは要らないです
ユーザー KyoroidKyoroid
提出日時 2020-04-03 23:20:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 11,076 KB
実行使用メモリ 19,132 KB
最終ジャッジ日時 2023-09-16 04:51:33
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
8,392 KB
testcase_02 AC 16 ms
8,268 KB
testcase_03 AC 16 ms
8,272 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 17 ms
8,200 KB
testcase_08 AC 16 ms
8,192 KB
testcase_09 AC 16 ms
8,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 233 ms
18,248 KB
testcase_16 AC 97 ms
18,728 KB
testcase_17 AC 247 ms
18,992 KB
testcase_18 AC 96 ms
18,572 KB
testcase_19 AC 239 ms
18,712 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,304 KB
testcase_31 AC 156 ms
10,092 KB
testcase_32 AC 154 ms
10,128 KB
testcase_33 AC 75 ms
19,012 KB
testcase_34 WA -
testcase_35 AC 16 ms
8,256 KB
testcase_36 AC 16 ms
8,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read():
    N, X, Y, Z = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    return N, X, Y, Z, A


def pay(a, v=1000):
    d = a % v
    a = a - d + v
    if v < 10000:
        nz = 0
    else:
        nz = a // 10000
    a -= nz * 10000
    if v < 5000:
        ny = 0
    else:
        ny = a // 5000
    a -= ny * 5000
    if v < 1000:
        nx = 0
    else:
        nx = a // 1000
    a -= nx * 1000
    return nx, ny, nz


def exchange(nx, ny, nz, X, Y, Z, INF=10**9+1):
    if nz > Z:
        ny += (nz - Z) * 2
        nz -= Z
    if ny > Y:
        nx += (ny - Y) * 5
        ny -= Y
    if nx > X:
        return INF, INF, INF
    return nx, ny, nz


def solve(N, X, Y, Z, A, INF=10**9+1):
    A = sorted(A, reverse=True)
    for a in A:
        nx, ny, nz = pay(a, 1000)
        nx, ny, nz = exchange(nx, ny, nz, X, Y, Z)
        if nx == INF:
            nx, ny, nz = pay(a, 5000)
            nx, ny, nz = exchange(nx, ny, nz, X, Y, Z)
            if nx == INF:
                nx, ny, nz = pay(a, 10000)
                nx, ny, nz = exchange(nx, ny, nz, X, Y, Z)
                if nx == INF:
                    return "No"
        X -= nx
        Y -= ny
        Z -= nz
    return "Yes"


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))
0