結果

問題 No.158 奇妙なお使い
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-02 19:39:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,919 ms / 5,000 ms
コード長 698 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 86,140 KB
最終ジャッジ日時 2023-09-11 11:25:09
合計ジャッジ時間 4,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,792 KB
testcase_01 AC 20 ms
8,428 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 17 ms
7,780 KB
testcase_04 AC 1,919 ms
86,140 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 16 ms
7,888 KB
testcase_07 AC 17 ms
7,960 KB
testcase_08 AC 16 ms
7,724 KB
testcase_09 AC 16 ms
7,784 KB
testcase_10 AC 19 ms
8,192 KB
testcase_11 AC 17 ms
8,208 KB
testcase_12 AC 16 ms
7,904 KB
testcase_13 AC 16 ms
7,816 KB
testcase_14 AC 20 ms
8,312 KB
testcase_15 AC 26 ms
8,596 KB
testcase_16 AC 17 ms
8,272 KB
testcase_17 AC 45 ms
9,616 KB
testcase_18 AC 275 ms
18,896 KB
testcase_19 AC 18 ms
8,200 KB
testcase_20 AC 19 ms
8,364 KB
testcase_21 AC 56 ms
10,264 KB
testcase_22 AC 57 ms
13,584 KB
testcase_23 AC 17 ms
8,180 KB
testcase_24 AC 17 ms
7,848 KB
testcase_25 AC 16 ms
7,832 KB
testcase_26 AC 19 ms
8,264 KB
testcase_27 AC 16 ms
7,776 KB
testcase_28 AC 24 ms
8,604 KB
testcase_29 AC 17 ms
8,248 KB
testcase_30 AC 47 ms
9,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)
a3, a2, a1 = map(int, input().split())
db = int(input())
b3, b2, b1 = map(int, input().split())
dc = int(input())
c3, c2, c1 = map(int, input().split())
m = dict()
def g(a3, a2, a1, b3, b2, b1, d):
    for d3 in range(min(d//1000, a3), -1, -1):
        for d2 in range(min((d - d3*1000)//100,a2), -1, -1):
            d1 = d - d3*1000 - d2*100
            if d1 > a1:continue
            return dfs(a3-d3+b3, a2-d2+b2, a1-d1+b1) + 1
    return 0
def dfs(a3, a2, a1):
    global m
    if (a3, a2, a1) in m: return m[a3, a2, a1]
    t = max(g(a3, a2, a1, b3, b2, b1, db), g(a3, a2, a1, c3, c2, c1, dc))
    m[a3, a2, a1] = t
    return t
print(dfs(a3, a2, a1))
0