結果

問題 No.1015 おつりは要らないです
ユーザー kurimupykurimupy
提出日時 2020-06-12 23:41:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 98,284 KB
最終ジャッジ日時 2023-09-06 11:28:42
合計ジャッジ時間 9,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,444 KB
testcase_01 AC 76 ms
71,628 KB
testcase_02 AC 75 ms
71,232 KB
testcase_03 AC 75 ms
71,320 KB
testcase_04 AC 75 ms
71,636 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 76 ms
71,436 KB
testcase_08 AC 77 ms
71,564 KB
testcase_09 AC 75 ms
71,444 KB
testcase_10 AC 261 ms
97,620 KB
testcase_11 AC 264 ms
97,744 KB
testcase_12 AC 253 ms
97,692 KB
testcase_13 AC 255 ms
97,880 KB
testcase_14 AC 268 ms
97,864 KB
testcase_15 AC 257 ms
97,992 KB
testcase_16 AC 261 ms
97,752 KB
testcase_17 AC 268 ms
97,708 KB
testcase_18 AC 261 ms
97,720 KB
testcase_19 AC 262 ms
97,584 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 80 ms
71,644 KB
testcase_31 AC 151 ms
95,824 KB
testcase_32 AC 150 ms
95,768 KB
testcase_33 AC 160 ms
98,284 KB
testcase_34 AC 80 ms
71,256 KB
testcase_35 AC 78 ms
71,516 KB
testcase_36 AC 80 ms
71,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# problem 3
import math
import heapq
N, X, Y, Z = map(int, input().split())

A = list(map(int, input().split()))

B = []
for num in A:
    B.append(-num-1)
heapq.heapify(B)

flag = True
# 10000円処理のケース

while flag and B:
    x = heapq.heappop(B)*(-1)
    if x < 10000:
        flag = False
        heapq.heappush(B, -x)
        continue

    elif x >= 10000:
        u, v = divmod(x, 10000)
        if u < Z:
            Z -= u
            heapq.heappush(B, -v)
            continue
        elif u >= Z:
            x -= Z*10000
            Z=0
            heapq.heappush(B, -x)
            flag = False
if not B:
    print("Yes")
    exit()


flag = True
# 5000円のケース
while flag and B:
    x = heapq.heappop(B)*(-1)
    if x < 5000:
        flag = False
        heapq.heappush(B, -x)
        continue

    elif x >= 5000:
        u, v = divmod(x, 5000)
        if u < Y:
            Y -= u
            heapq.heappush(B, -v)
            continue
        elif u >= Y:
            x -= Y*5000
            Y=0
            heapq.heappush(B, -x)
            flag = False
if not B:
    print("Yes")
    exit()

# 1000円の場合
flag = True
judge = True
Left=Y+Z
while B and flag:
    x = heapq.heappop(B)*(-1)
    if Left > 0:
        Left -= 1
        continue
    else:
        u = math.ceil(x/1000)
        if X >= u:
            X -= u
            continue
        else:
            flag = False
            judge = False
            continue
if judge:
    print("Yes")
else:
    print("No")
0