結果

問題 No.1015 おつりは要らないです
ユーザー ptotq
提出日時 2020-04-03 22:02:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,632 KB
最終ジャッジ日時 2024-11-17 23:10:58
合計ジャッジ時間 7,884 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, X, Y, Z = map(int, input().split())
a = list(map(lambda x: int(x) // 1000 * 1000 + 1000, input().split()))

for i in range(N):
    if a[i] >= 10000:
        n = min(Z, a[i]//10000)
        a[i] -= n * 10000
        Z -= n

a.sort(reverse=True)

for i in range(N):
    if a[i] <= 0:
        break
    if a[i] >= 5000 and Z:
        a[i] -= 10000
        Z -= 1
        continue
    if a[i] >= 5000:
        n = min(Y, a[i]//5000)
        a[i] -= n * 5000
        Y -= n

a.sort(reverse=True)

for i in range(N):
    if a[i] <= 0:
        break
    if a[i] > 0 and Z:
        a[i] -= 10000
        Z -= 1
    if a[i] > 0 and Y:
        a[i] -= 5000
        Y -= 1
    if a[i] > 0:
        n = min(a[i] // 1000, X)
        a[i] -= 1000*n
        X -= n

print('Yes' if max(a) <= 0 else 'No')
0