結果

問題 No.1015 おつりは要らないです
ユーザー shikixyx
提出日時 2020-04-03 22:43:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,271 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,648 KB
最終ジャッジ日時 2024-07-03 05:05:55
合計ジャッジ時間 7,340 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, X, Y, Z = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(N):
    if Z == 0:
        break

    a = A[i]
    man = a // 10000
    if man == 0:
        continue
    num = man if man <= Z else Z
    A[i] -= num * 10000
    Z -= num


for i in range(N):
    if Y == 0:
        break

    a = A[i]
    gosen = a // 5000
    if gosen == 0:
        continue
    num = gosen if gosen <= Y else Y
    A[i] -= num * 5000
    Y -= num

A.sort(reverse=True)

#print("A", A)
#print("XYZ", X, Y, Z)

for i in range(N):
    a = A[i]

    if a == 0:
        a = 1

    if Z > 0:
        man = -(-a // 10000)
        num = man if man <= Z else Z
        a -= num * 10000
        Z -= num

    if a > 0 and Y > 0:
        gosen = -(-a // 5000)
        num = gosen if gosen <= Y else Y
        a -= num * 5000
        Y -= num

    if a > 0 and X > 0:
        sen = -(-a // 1000)
        num = sen if X <= sen else X
        a -= num * 1000
        X -= num

    if a >= 0:
        print('No')
        exit()

    if X < 0 or Y < 0 or Z < 0:
        print('No')
        exit()

print('Yes')
exit()
0