結果

問題 No.158 奇妙なお使い
ユーザー tnodinotnodino
提出日時 2022-07-09 19:33:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,071 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,088 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-30 03:43:59
合計ジャッジ時間 8,971 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,200 KB
testcase_01 AC 1,682 ms
8,384 KB
testcase_02 AC 45 ms
8,228 KB
testcase_03 AC 16 ms
8,228 KB
testcase_04 TLE -
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 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
setrecursionlimit(10**6)

def check(x1000, x100, x1, d, d1000, d100, d1):
    m = d // 1000
    if m <= x1000:
        d %= 1000
        x1000 -= m
    else:
        d -= x1000 * 1000
        x1000 = 0
    m = d // 100
    if m <= x100:
        d %= 100
        x100 -= m
    else:
        d -= x100 * 100
        x100 = 0
    if d <= x1:
        x1 -= d
        x1000 += d1000
        x100 += d100
        x1 += d1
        return True, x1000, x100, x1
    else:
        return False, -1, -1, -1

def dfs(x1000, x100, x1):
    ret = 0
    flg,b1000,b100,b1 = check(x1000, x100, x1, Db, B1000, B100, B1)
    if flg:
        ret = max(ret, dfs(b1000, b100, b1) + 1)
    flg,c1000,c100,c1 = check(x1000, x100, x1, Dc, C1000, C100, C1)
    if flg:
        ret = max(ret, dfs(c1000, c100, c1) + 1)
    memo[x1000, x100, x1] = ret
    return ret

A1000,A100,A1 = map(int,input().split())
Db = int(input())
B1000,B100,B1 = map(int,input().split())
Dc = int(input())
C1000,C100,C1 = map(int,input().split())
memo = {}
print(dfs(A1000, A100, A1))
0