結果

問題 No.1015 おつりは要らないです
ユーザー nagitaosunagitaosu
提出日時 2020-04-03 22:18:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 1,202 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,780 KB
最終ジャッジ日時 2024-04-29 01:15:06
合計ジャッジ時間 6,337 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 33 ms
10,624 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 32 ms
10,752 KB
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 218 ms
21,332 KB
testcase_11 AC 223 ms
21,336 KB
testcase_12 AC 208 ms
20,956 KB
testcase_13 AC 218 ms
21,188 KB
testcase_14 AC 223 ms
21,780 KB
testcase_15 AC 210 ms
20,892 KB
testcase_16 AC 220 ms
21,164 KB
testcase_17 AC 223 ms
21,648 KB
testcase_18 AC 209 ms
20,996 KB
testcase_19 AC 216 ms
21,264 KB
testcase_20 AC 181 ms
21,120 KB
testcase_21 AC 182 ms
20,936 KB
testcase_22 AC 184 ms
20,908 KB
testcase_23 AC 175 ms
20,528 KB
testcase_24 AC 194 ms
21,304 KB
testcase_25 AC 184 ms
21,040 KB
testcase_26 AC 186 ms
21,020 KB
testcase_27 AC 182 ms
20,812 KB
testcase_28 AC 178 ms
21,012 KB
testcase_29 AC 188 ms
21,148 KB
testcase_30 AC 30 ms
10,880 KB
testcase_31 AC 127 ms
12,544 KB
testcase_32 AC 123 ms
12,672 KB
testcase_33 AC 136 ms
21,492 KB
testcase_34 AC 32 ms
10,752 KB
testcase_35 AC 31 ms
10,752 KB
testcase_36 AC 32 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, x, y, z = map(int, input().split())
a = [int(item) for item in input().split()]
over_five = []
under_five = []

pay_first = 0
for item in a:
    if item % 1000 != 999:
        item += 1
    pay_first += (item // 10000) * 10000
    if item % 10000 >= 5000:
        over_five.append(item % 10000)
    elif item % 10000 > 0:
        under_five.append(item % 10000)

payment = min(z*10000, pay_first)
z -= payment // 10000; pay_first -= payment

payment = min(y*5000, pay_first)
y -= payment // 5000; pay_first -= payment

payment = min(x*1000, pay_first)
x -= payment // 1000; pay_first -= payment

if pay_first > 0:
    print("No")
    exit()

over_five.sort(reverse=True)
for i, item in enumerate(over_five):
    if z > 0:
        z -= 1
        continue
    if y > 0:
        y -= 1
        under_five.append(item - 5000)
        continue
    under_five.append(item)

under_five.sort(reverse=True)

for item in under_five:
    if z > 0:
        z -= 1
        continue
    if y > 0:
        y -= 1
        continue
    use = (item + 999) // 1000
    if x >= use:
        x -= use
    else:
        print("No")
        exit()
print("Yes")
0