結果

問題 No.158 奇妙なお使い
ユーザー roiti46roiti46
提出日時 2015-03-01 18:43:43
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 963 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 6,664 KB
実行使用メモリ 93,712 KB
最終ジャッジ日時 2023-09-06 05:54:30
合計ジャッジ時間 9,098 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 234 ms
92,844 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(a1,a2,a3):
    if memo[a1][a2][a3] >= 0: return memo[a1][a2][a3]
    res = 0
    if 1000*a1+100*a2+a3 >= Db:
        x1,x2,x3,db = a1,a2,a3,Db
        while x1 and db >= 1000: db -= 1000; x1 -= 1
        while x2 and db >=  100: db -=  100; x2 -= 1
        while x3 and db >=    1: db -=    1; x3 -= 1
        if db == 0: res = max(res, solve(x1+B1, x2+B2, x3+B3)+1)


    if 1000*a1+100*a2+a3 >= Dc:
        x1,x2,x3,db = a1,a2,a3,Db
        while x1 and dc >= 1000: dc -= 1000; x1 -= 1
        while x2 and dc >=  100: dc -=  100; x2 -= 1
        while x3 and dc >=    1: dc -=    1; x3 -= 1
        if dc == 0: res = max(res, solve(x1+C1, x2+C2, x3+C3)+1)
    memo[a1][a2][a3] = res;
    return res;


A1,A2,A3 = map(int,raw_input().split())
Db = int(raw_input())
B1,B2,B3 = map(int,raw_input().split())
Dc = int(raw_input())
C1,C2,C3 = map(int,raw_input().split())
memo = [[[-1]*10001 for i in xrange(101)] for j in xrange(11)]
print solve(A1,A2,A3)
0