結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 17 ms
8,308 KB
testcase_02 AC 17 ms
8,096 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 17 ms
8,156 KB
testcase_08 AC 17 ms
8,020 KB
testcase_09 AC 17 ms
8,016 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 346 ms
18,236 KB
testcase_16 AC 350 ms
18,632 KB
testcase_17 AC 366 ms
18,892 KB
testcase_18 AC 347 ms
18,600 KB
testcase_19 AC 353 ms
18,672 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 17 ms
8,228 KB
testcase_31 WA -
testcase_32 AC 49 ms
10,008 KB
testcase_33 AC 68 ms
18,988 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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