結果

問題 No.37 遊園地のアトラクション
ユーザー cologne
提出日時 2022-01-23 17:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 425 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,820 KB
実行使用メモリ 60,340 KB
最終ジャッジ日時 2025-01-01 18:35:18
合計ジャッジ時間 2,357 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    T = int(input())
    N = int(input())
    *C, = map(int, input().split())
    *V, = map(int, input().split())
    DP = [0]*(T+1)

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

    print(DP[-1])


if __name__ == '__main__':
    main()
0