結果

問題 No.37 遊園地のアトラクション
ユーザー ああいいああいい
提出日時 2021-12-29 20:36:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 71,864 KB
最終ジャッジ日時 2024-04-15 02:27:34
合計ジャッジ時間 2,867 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
67,388 KB
testcase_01 AC 46 ms
60,692 KB
testcase_02 AC 60 ms
67,892 KB
testcase_03 AC 63 ms
68,096 KB
testcase_04 AC 58 ms
68,352 KB
testcase_05 AC 60 ms
69,724 KB
testcase_06 AC 58 ms
69,276 KB
testcase_07 AC 74 ms
69,040 KB
testcase_08 AC 56 ms
66,924 KB
testcase_09 AC 45 ms
61,356 KB
testcase_10 AC 71 ms
69,332 KB
testcase_11 AC 70 ms
69,356 KB
testcase_12 AC 60 ms
68,468 KB
testcase_13 AC 61 ms
68,872 KB
testcase_14 AC 57 ms
68,292 KB
testcase_15 AC 63 ms
71,268 KB
testcase_16 AC 69 ms
71,864 KB
testcase_17 AC 66 ms
70,180 KB
testcase_18 AC 72 ms
69,104 KB
testcase_19 AC 46 ms
63,136 KB
testcase_20 AC 62 ms
68,852 KB
testcase_21 AC 55 ms
66,388 KB
testcase_22 AC 70 ms
68,256 KB
testcase_23 AC 33 ms
53,188 KB
testcase_24 AC 34 ms
52,472 KB
testcase_25 AC 35 ms
53,220 KB
testcase_26 AC 35 ms
53,172 KB
testcase_27 AC 60 ms
68,860 KB
testcase_28 AC 35 ms
53,692 KB
testcase_29 AC 57 ms
68,928 KB
testcase_30 AC 34 ms
54,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
N = int(input())
c = list(map(int,input().split()))
v = list(map(int,input().split()))

dp = [[0] * (T+1) for _ in range(N+1)]
for i in range(N):
    for j in range(T + 1):
        if dp[i][j] > dp[i+1][j]:
            dp[i+1][j] = dp[i][j]
        value = v[i]
        now = 0
        cost = c[i]
        k = 1
        while j + cost * k <= T and value > 0:
            now += value
            dp[i+1][j+cost * k] = max(dp[i+1][j+cost * k],dp[i][j] + now)
            value = value // 2
            k += 1
print(max(dp[N]))

            
0