結果

問題 No.158 奇妙なお使い
ユーザー roarisroaris
提出日時 2019-12-05 00:10:09
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,268 ms / 5,000 ms
コード長 914 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 109,716 KB
最終ジャッジ日時 2023-08-21 07:02:07
合計ジャッジ時間 11,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
95,228 KB
testcase_01 AC 278 ms
95,128 KB
testcase_02 AC 274 ms
95,192 KB
testcase_03 AC 276 ms
95,128 KB
testcase_04 AC 1,268 ms
109,716 KB
testcase_05 AC 278 ms
95,184 KB
testcase_06 AC 276 ms
95,024 KB
testcase_07 AC 274 ms
95,168 KB
testcase_08 AC 274 ms
95,080 KB
testcase_09 AC 275 ms
95,160 KB
testcase_10 AC 280 ms
95,088 KB
testcase_11 AC 276 ms
95,172 KB
testcase_12 AC 276 ms
95,156 KB
testcase_13 AC 277 ms
95,088 KB
testcase_14 AC 277 ms
95,088 KB
testcase_15 AC 280 ms
95,108 KB
testcase_16 AC 278 ms
95,208 KB
testcase_17 AC 294 ms
95,220 KB
testcase_18 AC 418 ms
97,072 KB
testcase_19 AC 275 ms
95,200 KB
testcase_20 AC 278 ms
95,264 KB
testcase_21 AC 294 ms
95,976 KB
testcase_22 AC 297 ms
97,488 KB
testcase_23 AC 276 ms
95,088 KB
testcase_24 AC 274 ms
95,220 KB
testcase_25 AC 276 ms
95,068 KB
testcase_26 AC 275 ms
95,216 KB
testcase_27 AC 276 ms
95,144 KB
testcase_28 AC 278 ms
95,104 KB
testcase_29 AC 277 ms
95,236 KB
testcase_30 AC 284 ms
95,204 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