結果

問題 No.1015 おつりは要らないです
ユーザー kurimupykurimupy
提出日時 2020-06-12 23:33:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,514 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 86,800 KB
実行使用メモリ 97,864 KB
最終ジャッジ日時 2023-09-06 11:28:19
合計ジャッジ時間 7,123 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
71,004 KB
testcase_01 AC 77 ms
71,356 KB
testcase_02 AC 78 ms
71,388 KB
testcase_03 AC 77 ms
71,356 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 78 ms
71,368 KB
testcase_08 AC 79 ms
71,456 KB
testcase_09 AC 77 ms
71,088 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 161 ms
97,516 KB
testcase_16 AC 161 ms
97,456 KB
testcase_17 AC 163 ms
97,584 KB
testcase_18 AC 158 ms
97,412 KB
testcase_19 AC 159 ms
97,504 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 78 ms
71,368 KB
testcase_31 AC 146 ms
95,440 KB
testcase_32 AC 146 ms
95,596 KB
testcase_33 AC 129 ms
97,864 KB
testcase_34 AC 77 ms
71,084 KB
testcase_35 WA -
testcase_36 AC 77 ms
71,444 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 -= u*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 -= u*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