結果

問題 No.158 奇妙なお使い
ユーザー roarisroaris
提出日時 2019-12-05 00:09:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 873 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 95,644 KB
最終ジャッジ日時 2023-08-21 07:01:21
合計ジャッジ時間 11,668 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 279 ms
95,164 KB
testcase_01 AC 277 ms
95,168 KB
testcase_02 AC 275 ms
95,128 KB
testcase_03 AC 276 ms
95,088 KB
testcase_04 RE -
testcase_05 AC 273 ms
95,080 KB
testcase_06 AC 272 ms
95,024 KB
testcase_07 AC 274 ms
95,028 KB
testcase_08 AC 274 ms
95,004 KB
testcase_09 AC 273 ms
95,024 KB
testcase_10 AC 274 ms
95,156 KB
testcase_11 AC 275 ms
95,176 KB
testcase_12 AC 272 ms
95,140 KB
testcase_13 AC 273 ms
95,032 KB
testcase_14 AC 275 ms
95,092 KB
testcase_15 AC 283 ms
95,196 KB
testcase_16 AC 277 ms
95,160 KB
testcase_17 AC 292 ms
95,392 KB
testcase_18 RE -
testcase_19 AC 277 ms
95,060 KB
testcase_20 AC 277 ms
95,136 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 278 ms
95,040 KB
testcase_24 AC 275 ms
95,136 KB
testcase_25 AC 274 ms
95,084 KB
testcase_26 AC 274 ms
95,104 KB
testcase_27 AC 273 ms
95,124 KB
testcase_28 AC 278 ms
95,164 KB
testcase_29 AC 274 ms
95,104 KB
testcase_30 AC 284 ms
95,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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