結果

問題 No.1015 おつりは要らないです
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-27 15:30:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 415 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,684 KB
最終ジャッジ日時 2024-04-29 06:17:00
合計ジャッジ時間 10,306 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 389 ms
21,256 KB
testcase_11 AC 404 ms
21,452 KB
testcase_12 AC 367 ms
20,820 KB
testcase_13 AC 394 ms
21,172 KB
testcase_14 AC 415 ms
21,684 KB
testcase_15 AC 388 ms
20,856 KB
testcase_16 AC 398 ms
21,156 KB
testcase_17 AC 402 ms
21,536 KB
testcase_18 AC 392 ms
20,988 KB
testcase_19 AC 393 ms
20,960 KB
testcase_20 AC 396 ms
21,240 KB
testcase_21 AC 380 ms
21,024 KB
testcase_22 AC 382 ms
20,900 KB
testcase_23 AC 361 ms
20,680 KB
testcase_24 AC 382 ms
21,168 KB
testcase_25 AC 382 ms
20,984 KB
testcase_26 AC 386 ms
20,872 KB
testcase_27 AC 374 ms
20,804 KB
testcase_28 AC 367 ms
20,788 KB
testcase_29 AC 382 ms
21,060 KB
testcase_30 AC 31 ms
10,752 KB
testcase_31 AC 150 ms
12,504 KB
testcase_32 AC 68 ms
12,632 KB
testcase_33 AC 91 ms
21,604 KB
testcase_34 AC 31 ms
10,752 KB
testcase_35 AC 31 ms
10,752 KB
testcase_36 AC 32 ms
10,752 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 z == 0:
        break
    a = -heappop(A)
    if a >= 10000:
        t = min(a // 10000, z)
        z -= t
        a -= 10000 * t
        heappush(A, -a)
    else:
        z -= 1

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

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

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