結果

問題 No.158 奇妙なお使い
ユーザー roarisroaris
提出日時 2019-12-05 00:10:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 820 ms / 5,000 ms
コード長 914 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 180,400 KB
最終ジャッジ日時 2023-08-21 07:04:34
合計ジャッジ時間 7,374 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
159,112 KB
testcase_01 AC 156 ms
159,480 KB
testcase_02 AC 154 ms
159,184 KB
testcase_03 AC 152 ms
159,092 KB
testcase_04 AC 820 ms
180,400 KB
testcase_05 AC 156 ms
159,196 KB
testcase_06 AC 157 ms
159,272 KB
testcase_07 AC 154 ms
159,180 KB
testcase_08 AC 155 ms
159,224 KB
testcase_09 AC 155 ms
159,292 KB
testcase_10 AC 157 ms
159,236 KB
testcase_11 AC 157 ms
159,228 KB
testcase_12 AC 157 ms
159,240 KB
testcase_13 AC 154 ms
159,204 KB
testcase_14 AC 157 ms
159,276 KB
testcase_15 AC 171 ms
159,828 KB
testcase_16 AC 157 ms
159,424 KB
testcase_17 AC 199 ms
164,508 KB
testcase_18 AC 215 ms
166,612 KB
testcase_19 AC 152 ms
159,248 KB
testcase_20 AC 158 ms
159,456 KB
testcase_21 AC 188 ms
165,800 KB
testcase_22 AC 197 ms
171,632 KB
testcase_23 AC 155 ms
159,324 KB
testcase_24 AC 154 ms
159,284 KB
testcase_25 AC 154 ms
159,216 KB
testcase_26 AC 157 ms
159,364 KB
testcase_27 AC 155 ms
159,268 KB
testcase_28 AC 164 ms
159,612 KB
testcase_29 AC 154 ms
159,292 KB
testcase_30 AC 179 ms
160,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**8)

def rec(i, j, k):
    if memo[i][j][k]!=-1:
        return memo[i][j][k]
    
    res = 0
    
    Db_ = Db
    use1000 = min(Db_//1000, i)
    Db_ -= use1000*1000
    use100 = min(Db_//100, j)
    Db_ -= use100*100
    
    if Db_<=k:
        use1 = Db_
        res = max(res, rec(i-use1000+B1000, j-use100+B100, k-use1+B1)+1)
    
    Dc_ = Dc
    use1000 = min(Dc_//1000, i)
    Dc_ -= use1000*1000
    use100 = min(Dc_//100, j)
    Dc_ -= use100*100
    
    if Dc_<=k:
        use1 = Dc_
        res = max(res, rec(i-use1000+C1000, j-use100+C100, k-use1+C1)+1)
    
    memo[i][j][k] = res
    
    return res

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 = [[[-1]*10001 for _ in range(101)] for _ in range(11)]

print(rec(A1000, A100, A1))
0