結果

問題 No.37 遊園地のアトラクション
ユーザー ntuda
提出日時 2024-12-24 21:56:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 345 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 75,136 KB
最終ジャッジ日時 2024-12-24 21:56:32
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
N = int(input())
C = list(map(int, input().split()))
V = list(map(int, input().split()))

dp = [0] * (T + 1)
for i in range(N):
    c = C[i]
    v = V[i]
    j = 0
    while v > 0:
        for i in reversed(range(j * c, T - c + 1)):
            dp[i + c] = max(dp[i + c], dp[i] + v)
        j += 1
        v //= 2
print(dp[-1])
0