結果

問題 No.1015 おつりは要らないです
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-27 15:34:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 90,812 KB
最終ジャッジ日時 2024-04-29 06:17:15
合計ジャッジ時間 6,264 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,316 KB
testcase_01 AC 33 ms
52,360 KB
testcase_02 AC 34 ms
53,724 KB
testcase_03 AC 33 ms
53,000 KB
testcase_04 AC 31 ms
53,380 KB
testcase_05 AC 32 ms
54,076 KB
testcase_06 AC 31 ms
53,080 KB
testcase_07 AC 33 ms
53,684 KB
testcase_08 AC 34 ms
53,076 KB
testcase_09 AC 33 ms
53,508 KB
testcase_10 AC 197 ms
90,104 KB
testcase_11 AC 190 ms
90,812 KB
testcase_12 AC 177 ms
89,932 KB
testcase_13 AC 183 ms
90,320 KB
testcase_14 AC 189 ms
90,204 KB
testcase_15 AC 184 ms
90,460 KB
testcase_16 AC 188 ms
90,260 KB
testcase_17 AC 187 ms
90,808 KB
testcase_18 AC 185 ms
90,420 KB
testcase_19 AC 184 ms
90,536 KB
testcase_20 AC 197 ms
90,000 KB
testcase_21 AC 190 ms
89,820 KB
testcase_22 AC 196 ms
89,772 KB
testcase_23 AC 193 ms
89,760 KB
testcase_24 AC 212 ms
90,352 KB
testcase_25 AC 193 ms
90,080 KB
testcase_26 AC 196 ms
90,312 KB
testcase_27 AC 193 ms
90,012 KB
testcase_28 AC 194 ms
90,224 KB
testcase_29 AC 192 ms
89,968 KB
testcase_30 AC 33 ms
53,820 KB
testcase_31 AC 91 ms
88,376 KB
testcase_32 AC 69 ms
88,140 KB
testcase_33 AC 76 ms
90,668 KB
testcase_34 AC 35 ms
52,088 KB
testcase_35 AC 32 ms
52,856 KB
testcase_36 AC 31 ms
52,748 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:
        t = min(a // 10000, z)
        z -= t
        a -= 10000 * t
        heappush(A, -a)
    else:
        z -= 1

while A:
    if not y:
        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 not x:
        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