結果

問題 No.1015 おつりは要らないです
ユーザー nagitaosunagitaosu
提出日時 2020-04-03 22:18:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 1,202 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 19,272 KB
最終ジャッジ日時 2023-08-11 08:42:40
合計ジャッジ時間 5,334 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,192 KB
testcase_01 AC 15 ms
8,200 KB
testcase_02 AC 15 ms
8,252 KB
testcase_03 AC 16 ms
8,176 KB
testcase_04 AC 16 ms
8,312 KB
testcase_05 AC 16 ms
8,176 KB
testcase_06 AC 16 ms
8,344 KB
testcase_07 AC 16 ms
8,312 KB
testcase_08 AC 16 ms
8,256 KB
testcase_09 AC 16 ms
8,192 KB
testcase_10 AC 165 ms
18,848 KB
testcase_11 AC 171 ms
19,024 KB
testcase_12 AC 163 ms
18,340 KB
testcase_13 AC 172 ms
18,456 KB
testcase_14 AC 174 ms
19,272 KB
testcase_15 AC 163 ms
18,508 KB
testcase_16 AC 165 ms
18,792 KB
testcase_17 AC 172 ms
18,988 KB
testcase_18 AC 168 ms
18,492 KB
testcase_19 AC 165 ms
18,808 KB
testcase_20 AC 141 ms
18,728 KB
testcase_21 AC 140 ms
18,644 KB
testcase_22 AC 141 ms
18,512 KB
testcase_23 AC 137 ms
18,380 KB
testcase_24 AC 143 ms
18,884 KB
testcase_25 AC 148 ms
18,496 KB
testcase_26 AC 138 ms
18,528 KB
testcase_27 AC 139 ms
18,452 KB
testcase_28 AC 136 ms
18,608 KB
testcase_29 AC 142 ms
18,812 KB
testcase_30 AC 15 ms
8,252 KB
testcase_31 AC 96 ms
10,004 KB
testcase_32 AC 100 ms
10,028 KB
testcase_33 AC 102 ms
19,052 KB
testcase_34 AC 15 ms
8,308 KB
testcase_35 AC 15 ms
8,188 KB
testcase_36 AC 15 ms
7,784 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