結果

問題 No.1015 おつりは要らないです
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-27 15:14:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 860 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2023-09-18 19:31:07
合計ジャッジ時間 9,048 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,992 KB
testcase_01 AC 16 ms
8,280 KB
testcase_02 WA -
testcase_03 AC 16 ms
8,060 KB
testcase_04 AC 16 ms
8,084 KB
testcase_05 AC 16 ms
8,048 KB
testcase_06 AC 16 ms
8,184 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 401 ms
18,688 KB
testcase_11 AC 411 ms
18,924 KB
testcase_12 AC 389 ms
18,408 KB
testcase_13 AC 398 ms
18,628 KB
testcase_14 AC 405 ms
19,328 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 305 ms
18,804 KB
testcase_21 AC 292 ms
18,652 KB
testcase_22 AC 299 ms
18,696 KB
testcase_23 AC 283 ms
18,164 KB
testcase_24 AC 297 ms
18,852 KB
testcase_25 AC 293 ms
18,772 KB
testcase_26 AC 289 ms
18,596 KB
testcase_27 AC 283 ms
18,652 KB
testcase_28 AC 284 ms
18,576 KB
testcase_29 AC 301 ms
18,852 KB
testcase_30 AC 16 ms
8,392 KB
testcase_31 AC 96 ms
10,092 KB
testcase_32 AC 48 ms
10,052 KB
testcase_33 AC 67 ms
19,052 KB
testcase_34 AC 17 ms
7,992 KB
testcase_35 AC 16 ms
8,016 KB
testcase_36 AC 17 ms
8,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heapify, heappush
n, x, y, z = map(int, input().split())
A = list(int(-a) for a in map(int, input().split()))
heapify(A)

if n > x + y + z or -sum(A) >= x * 1000 + y * 5000 + z * 10000:
    print("No")
    exit()

while A:
    if not z:
        break
    a = -heappop(A)
    if a >= 10000:
        use = min(a//10000, z)
        z -= use
        a -= use * 10000
        heappush(A, -a)
    else:
        z = -1

while A:
    if not y:
        break
    a = -heappop(A)
    if a >= 5000:
        use = min(a//5000, y)
        y -= use
        a -= use * 5000
        heappush(A, -a)
    else:
        y = -1

while A:
    if not x:
        break
    a = -heappop(A)
    if a >= 1000:
        use = min(a//1000, x)
        x -= use
        a -= use * 1000
        heappush(A, -a)
    else:
        x = -1

print("No" if A else "Yes")
0