結果

問題 No.1015 おつりは要らないです
ユーザー c-yanc-yan
提出日時 2020-07-30 03:45:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,692 KB
最終ジャッジ日時 2024-04-29 06:18:52
合計ジャッジ時間 8,930 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 27 ms
10,624 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 24 ms
10,752 KB
testcase_05 AC 24 ms
10,752 KB
testcase_06 AC 25 ms
10,624 KB
testcase_07 AC 25 ms
10,624 KB
testcase_08 AC 24 ms
10,752 KB
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 393 ms
21,132 KB
testcase_11 AC 410 ms
21,424 KB
testcase_12 AC 370 ms
20,920 KB
testcase_13 AC 390 ms
21,268 KB
testcase_14 AC 395 ms
21,692 KB
testcase_15 AC 375 ms
21,068 KB
testcase_16 AC 392 ms
21,120 KB
testcase_17 AC 392 ms
21,564 KB
testcase_18 AC 382 ms
21,080 KB
testcase_19 AC 374 ms
21,048 KB
testcase_20 AC 312 ms
21,088 KB
testcase_21 AC 320 ms
21,112 KB
testcase_22 AC 311 ms
20,992 KB
testcase_23 AC 298 ms
20,780 KB
testcase_24 AC 321 ms
21,260 KB
testcase_25 AC 309 ms
21,120 KB
testcase_26 AC 314 ms
20,968 KB
testcase_27 AC 301 ms
20,900 KB
testcase_28 AC 315 ms
20,760 KB
testcase_29 AC 314 ms
21,076 KB
testcase_30 AC 25 ms
10,624 KB
testcase_31 AC 98 ms
12,544 KB
testcase_32 AC 101 ms
12,544 KB
testcase_33 AC 84 ms
21,564 KB
testcase_34 AC 25 ms
10,752 KB
testcase_35 AC 26 ms
10,752 KB
testcase_36 AC 27 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush

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

numbers = [Z, Y, X]
bills = [10000, 5000, 1000]

A = [-n for n in A]
heapify(A)

for i in range(3):
    n = numbers[i]
    b = bills[i]

    while A:
        if n == 0:
            break
        x = -heappop(A)
        if x >= b:
            t = min(x // b, n)
            n -= t
            x -= b * t
            heappush(A, -x)
        else:
            n -= 1

if len(A) == 0:
    print('Yes')
else:
    print('No')
0