結果

問題 No.158 奇妙なお使い
ユーザー roiti46roiti46
提出日時 2015-03-01 18:47:44
言語 PyPy2
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,004 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 78,128 KB
実行使用メモリ 612,084 KB
最終ジャッジ日時 2023-09-06 05:56:22
合計ジャッジ時間 9,562 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
148,800 KB
testcase_01 AC 177 ms
166,768 KB
testcase_02 AC 140 ms
148,732 KB
testcase_03 AC 137 ms
148,556 KB
testcase_04 MLE -
testcase_05 AC 148 ms
148,136 KB
testcase_06 AC 142 ms
148,364 KB
testcase_07 AC 141 ms
148,420 KB
testcase_08 AC 143 ms
148,640 KB
testcase_09 AC 144 ms
148,760 KB
testcase_10 AC 153 ms
148,508 KB
testcase_11 AC 153 ms
148,704 KB
testcase_12 AC 145 ms
148,256 KB
testcase_13 AC 142 ms
149,088 KB
testcase_14 AC 178 ms
166,668 KB
testcase_15 AC 179 ms
166,756 KB
testcase_16 AC 150 ms
149,308 KB
testcase_17 AC 191 ms
166,972 KB
testcase_18 AC 207 ms
169,328 KB
testcase_19 AC 145 ms
148,968 KB
testcase_20 AC 155 ms
149,136 KB
testcase_21 AC 215 ms
171,636 KB
testcase_22 AC 205 ms
175,292 KB
testcase_23 AC 145 ms
148,520 KB
testcase_24 AC 142 ms
148,748 KB
testcase_25 AC 139 ms
148,784 KB
testcase_26 AC 153 ms
149,324 KB
testcase_27 AC 142 ms
148,488 KB
testcase_28 AC 180 ms
166,808 KB
testcase_29 AC 146 ms
148,560 KB
testcase_30 AC 193 ms
166,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(100000)
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,dc = a1,a2,a3,Dc
        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