結果

問題 No.1015 おつりは要らないです
ユーザー ttrttr
提出日時 2020-05-25 20:47:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,936 KB
最終ジャッジ日時 2024-04-29 06:14:52
合計ジャッジ時間 7,655 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 25 ms
11,008 KB
testcase_05 AC 24 ms
11,008 KB
testcase_06 AC 25 ms
10,880 KB
testcase_07 AC 24 ms
10,880 KB
testcase_08 AC 24 ms
10,880 KB
testcase_09 AC 24 ms
11,008 KB
testcase_10 AC 281 ms
21,496 KB
testcase_11 AC 280 ms
21,368 KB
testcase_12 AC 259 ms
20,984 KB
testcase_13 AC 286 ms
21,352 KB
testcase_14 AC 289 ms
21,936 KB
testcase_15 AC 260 ms
21,048 KB
testcase_16 AC 273 ms
21,320 KB
testcase_17 AC 281 ms
21,808 KB
testcase_18 AC 275 ms
21,280 KB
testcase_19 AC 282 ms
21,416 KB
testcase_20 AC 311 ms
21,152 KB
testcase_21 AC 291 ms
21,196 KB
testcase_22 AC 285 ms
21,068 KB
testcase_23 AC 277 ms
20,732 KB
testcase_24 AC 299 ms
21,340 KB
testcase_25 AC 296 ms
21,196 KB
testcase_26 AC 307 ms
21,048 KB
testcase_27 AC 291 ms
20,720 KB
testcase_28 AC 284 ms
20,796 KB
testcase_29 AC 305 ms
21,276 KB
testcase_30 AC 28 ms
10,880 KB
testcase_31 AC 116 ms
12,640 KB
testcase_32 AC 110 ms
12,768 KB
testcase_33 AC 98 ms
21,772 KB
testcase_34 AC 26 ms
10,752 KB
testcase_35 AC 24 ms
10,752 KB
testcase_36 AC 25 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,X,Y,Z = map(int, input().split())
A = [int(a) for a in input().split()]

h = []
for a in A:
    heapq.heappush(h, -a)

while Z > 0 and h:
    a = heapq.heappop(h)
    if a > -10000:
        Z -= 1
    elif Z >= abs(a)//10000:
        Z -= abs(a)//10000
        a = abs(a)%10000
        if a > 0:
            heapq.heappush(h, -a)
        elif a == 0 and X > 0:
            X -= 1
        elif a == 0 and Y > 0:
            Y -= 1
        elif a == 0:
            Z -= 1
    else:
        a += 10000*Z
        heapq.heappush(h, a)
        Z = 0

while Y > 0 and h:
    a = heapq.heappop(h)
    if a > -5000:
        Y -= 1
    elif Y >= abs(a)//5000:
        Y -= abs(a)//5000
        a = abs(a)%5000
        if a > 0:
            heapq.heappush(h, -a)
        elif a == 0 and X > 0:
            X -= 1
        elif a == 0:
            Y -= 1
    else:
        a += 5000*Y
        heapq.heappush(h, a)
        Y = 0

while X > 0 and h:
    a = -heapq.heappop(h)
    X -= (a-1)//1000+1

if len(h) == 0 and X >= 0 and Y >= 0 and Z >= 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)
0