結果

問題 No.158 奇妙なお使い
ユーザー roarisroaris
提出日時 2019-12-05 00:09:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 873 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 98,304 KB
最終ジャッジ日時 2024-05-08 12:27:25
合計ジャッジ時間 9,914 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 265 ms
97,664 KB
testcase_01 AC 266 ms
97,664 KB
testcase_02 AC 264 ms
97,664 KB
testcase_03 AC 263 ms
97,664 KB
testcase_04 RE -
testcase_05 AC 266 ms
97,792 KB
testcase_06 AC 262 ms
97,664 KB
testcase_07 AC 264 ms
97,664 KB
testcase_08 AC 261 ms
97,664 KB
testcase_09 AC 270 ms
97,664 KB
testcase_10 AC 273 ms
97,792 KB
testcase_11 AC 264 ms
97,792 KB
testcase_12 AC 270 ms
97,664 KB
testcase_13 AC 263 ms
97,664 KB
testcase_14 AC 268 ms
97,664 KB
testcase_15 AC 266 ms
97,536 KB
testcase_16 AC 264 ms
97,664 KB
testcase_17 AC 283 ms
97,792 KB
testcase_18 RE -
testcase_19 AC 263 ms
97,664 KB
testcase_20 AC 259 ms
97,792 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 262 ms
97,792 KB
testcase_24 AC 265 ms
97,536 KB
testcase_25 AC 258 ms
97,792 KB
testcase_26 AC 265 ms
97,664 KB
testcase_27 AC 263 ms
97,664 KB
testcase_28 AC 266 ms
97,664 KB
testcase_29 AC 264 ms
97,664 KB
testcase_30 AC 275 ms
97,664 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