結果

問題 No.1015 おつりは要らないです
ユーザー Mao-betaMao-beta
提出日時 2024-03-12 10:42:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 1,878 bytes
コンパイル時間 3,940 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 92,452 KB
最終ジャッジ日時 2024-03-12 10:42:36
合計ジャッジ時間 9,826 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,616 KB
testcase_01 AC 41 ms
55,616 KB
testcase_02 AC 46 ms
55,616 KB
testcase_03 AC 41 ms
55,616 KB
testcase_04 AC 41 ms
57,700 KB
testcase_05 AC 41 ms
57,700 KB
testcase_06 AC 48 ms
55,616 KB
testcase_07 AC 47 ms
57,700 KB
testcase_08 AC 43 ms
57,700 KB
testcase_09 AC 42 ms
57,700 KB
testcase_10 AC 245 ms
92,128 KB
testcase_11 AC 247 ms
92,320 KB
testcase_12 AC 237 ms
92,036 KB
testcase_13 AC 277 ms
92,264 KB
testcase_14 AC 250 ms
92,376 KB
testcase_15 AC 239 ms
92,060 KB
testcase_16 AC 254 ms
92,124 KB
testcase_17 AC 252 ms
92,200 KB
testcase_18 AC 267 ms
92,112 KB
testcase_19 AC 250 ms
92,100 KB
testcase_20 AC 221 ms
91,928 KB
testcase_21 AC 211 ms
91,900 KB
testcase_22 AC 209 ms
92,028 KB
testcase_23 AC 229 ms
91,760 KB
testcase_24 AC 213 ms
91,948 KB
testcase_25 AC 215 ms
92,028 KB
testcase_26 AC 214 ms
91,892 KB
testcase_27 AC 217 ms
91,868 KB
testcase_28 AC 233 ms
91,864 KB
testcase_29 AC 221 ms
92,040 KB
testcase_30 AC 42 ms
55,616 KB
testcase_31 AC 100 ms
89,836 KB
testcase_32 AC 100 ms
89,836 KB
testcase_33 AC 109 ms
92,452 KB
testcase_34 AC 41 ms
55,616 KB
testcase_35 AC 41 ms
55,616 KB
testcase_36 AC 41 ms
55,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    N, *X = NMI()
    A = NLI()
    A = [-a for a in A]
    heapify(A)
    while A:
        a = heappop(A)
        a = -a
        if X[2] > 0:
            if a < 10000:
                X[2] -= 1
                continue

            k, r = divmod(a, 10000)
            if X[2] >= k:
                X[2] -= k
                heappush(A, -r)
                continue
            else:
                heappush(A, -(a-10000*X[2]))
                X[2] = 0
                continue

        if X[1] > 0:
            if a < 5000:
                X[1] -= 1
                continue

            k, r = divmod(a, 5000)
            if X[1] >= k:
                X[1] -= k
                heappush(A, -r)
                continue
            else:
                heappush(A, -(a - 5000 * X[1]))
                X[1] = 0
                continue

        if X[0] > 0:
            if a < 1000:
                X[0] -= 1
                continue

            k, r = divmod(a, 1000)
            if X[0] >= k:
                X[0] -= k
                heappush(A, -r)
                continue
            elif 0 < X[0] < k:
                heappush(A, -(a - 1000 * X[0]))
                X[0] = 0
                continue

        print("No")
        return

    print("Yes")


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