結果

問題 No.1015 おつりは要らないです
ユーザー c-yanc-yan
提出日時 2020-04-03 23:17:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,804 KB
最終ジャッジ日時 2024-04-29 01:19:39
合計ジャッジ時間 8,094 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 25 ms
10,752 KB
testcase_02 AC 24 ms
10,624 KB
testcase_03 AC 24 ms
10,624 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 26 ms
10,624 KB
testcase_06 AC 25 ms
10,624 KB
testcase_07 AC 25 ms
10,880 KB
testcase_08 AC 25 ms
10,624 KB
testcase_09 AC 25 ms
10,752 KB
testcase_10 AC 297 ms
21,256 KB
testcase_11 AC 338 ms
21,444 KB
testcase_12 AC 332 ms
20,952 KB
testcase_13 AC 324 ms
21,168 KB
testcase_14 AC 324 ms
21,804 KB
testcase_15 AC 289 ms
20,976 KB
testcase_16 AC 303 ms
21,264 KB
testcase_17 AC 317 ms
21,532 KB
testcase_18 AC 310 ms
21,112 KB
testcase_19 AC 298 ms
20,952 KB
testcase_20 AC 302 ms
21,112 KB
testcase_21 AC 290 ms
21,020 KB
testcase_22 AC 291 ms
21,020 KB
testcase_23 AC 291 ms
20,680 KB
testcase_24 AC 302 ms
21,288 KB
testcase_25 AC 301 ms
21,148 KB
testcase_26 AC 303 ms
21,000 KB
testcase_27 AC 284 ms
20,796 KB
testcase_28 AC 306 ms
20,912 KB
testcase_29 AC 288 ms
21,184 KB
testcase_30 AC 25 ms
10,624 KB
testcase_31 AC 113 ms
12,628 KB
testcase_32 AC 113 ms
12,756 KB
testcase_33 AC 86 ms
21,728 KB
testcase_34 AC 25 ms
10,624 KB
testcase_35 AC 24 ms
10,624 KB
testcase_36 AC 24 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()))

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

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

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

while A:
    if X == 0:
        break
    x = -heappop(A)
    t = min((x + 1000) // 1000, X)
    X -= t
    x -= t * 1000
    if x >= 0:
        heappush(A, -x)

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