結果

問題 No.842 初詣
ユーザー Hitoshi Hayakawa
提出日時 2019-09-28 00:13:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 782 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,564 KB
最終ジャッジ日時 2024-09-25 03:17:51
合計ジャッジ時間 3,695 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

A, B, C, D, E, F, G = map(int, input().split())

def dfs(a, b, c, d, e, f, g):
    if g <= 0:
        return g == 0

    if a > 0:
        if dfs(a-1, b, c, d, e, f, g-500*a): return True
    if b > 0:
        if dfs(a, b-1, c, d, e, f, g-100*b): return True
    if c > 0:
        if dfs(a, b, c-1, d, e, f, g-50*c): return True
    if d > 0:
        if dfs(a, b, c, d-1, e, f, g-10*d): return True
    if e > 0:
        if dfs(a, b, c, d, e-1, f, g-5*e): return True
    if f > 0:
        if dfs(a, b, c, d, e, f-1, g-1*f): return True

    return False

print('YES' if dfs(A, B, C, D, E, F, G) else 'NO')
0