結果

問題 No.37 遊園地のアトラクション
ユーザー dangodango
提出日時 2023-07-09 15:58:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 516 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 86,272 KB
実行使用メモリ 87,664 KB
最終ジャッジ日時 2023-09-30 19:19:28
合計ジャッジ時間 5,266 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
76,176 KB
testcase_01 AC 89 ms
75,916 KB
testcase_02 AC 102 ms
75,900 KB
testcase_03 AC 98 ms
75,972 KB
testcase_04 AC 102 ms
76,784 KB
testcase_05 AC 108 ms
78,244 KB
testcase_06 AC 92 ms
76,108 KB
testcase_07 AC 127 ms
84,476 KB
testcase_08 AC 89 ms
76,152 KB
testcase_09 AC 83 ms
75,716 KB
testcase_10 AC 123 ms
82,680 KB
testcase_11 AC 118 ms
82,260 KB
testcase_12 AC 95 ms
75,856 KB
testcase_13 AC 96 ms
75,888 KB
testcase_14 AC 90 ms
76,132 KB
testcase_15 AC 105 ms
77,772 KB
testcase_16 AC 113 ms
79,912 KB
testcase_17 AC 104 ms
79,328 KB
testcase_18 AC 128 ms
84,344 KB
testcase_19 AC 84 ms
76,036 KB
testcase_20 AC 105 ms
78,776 KB
testcase_21 AC 83 ms
75,816 KB
testcase_22 AC 128 ms
87,664 KB
testcase_23 AC 71 ms
71,108 KB
testcase_24 AC 71 ms
71,188 KB
testcase_25 AC 72 ms
70,872 KB
testcase_26 AC 72 ms
71,248 KB
testcase_27 AC 105 ms
77,916 KB
testcase_28 AC 82 ms
76,172 KB
testcase_29 AC 100 ms
76,496 KB
testcase_30 AC 71 ms
70,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
n = int(input())
c = list(map(int, input().split()))
v = list(map(int, input().split()))
for i in range(n):
    x = v[i] // 2
    while x > 0:
        c.append(c[i])
        v.append(x)
        x //= 2
m = len(c)
dp = [[-float('inf')] * (t + 1) for _ in range(m + 1)]
dp[0][0] = 0
for i in range(m):
    for j in range(t + 1):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        if j + c[i] <= t:
            dp[i + 1][j + c[i]] = max(dp[i + 1][j + c[i]], dp[i][j] + v[i])
print(max(dp[-1]))
0