結果

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

ソースコード

diff #

#!/usr/bin/env python3
from typing import *

def foo(k, value, a):
    for i in range(len(a)):
        delta = min(k, a[i] // value)
        k -= delta
        a[i] -= delta * value
    a.sort()
    while k and a:
        assert a[-1] < value
        k -= 1
        a.pop()

def solve(n: int, x: int, y: int, z: int, a: List[int]) -> bool:
    foo(z, 10000, a)
    foo(y, 5000, a)
    foo(x, 1000, a)
    return not a

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    import sys
    tokens = iter(sys.stdin.read().split())
    N = int(next(tokens))
    X = int(next(tokens))
    Y = int(next(tokens))
    Z = int(next(tokens))
    A = [None for _ in range(N)]
    for i in range(N):
        A[i] = int(next(tokens))
    assert next(tokens, None) is None
    ans = solve(N, X, Y, Z, A)
    print(ans and 'Yes' or 'No')

if __name__ == '__main__':
    main()
0