結果

問題 No.842 初詣
ユーザー Hitoshi HayakawaHitoshi Hayakawa
提出日時 2019-09-28 00:13:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 782 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 11,788 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2023-10-25 08:04:01
合計ジャッジ時間 4,269 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
14,464 KB
testcase_01 AC 29 ms
10,092 KB
testcase_02 AC 29 ms
10,092 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

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