結果

問題 No.842 初詣
ユーザー Hitoshi HayakawaHitoshi Hayakawa
提出日時 2019-09-28 00:13:47
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 782 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 84,888 KB
最終ジャッジ日時 2023-10-25 08:04:17
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,440 KB
testcase_01 AC 38 ms
53,408 KB
testcase_02 AC 39 ms
53,408 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