結果

問題 No.37 遊園地のアトラクション
ユーザー 👑 colognecologne
提出日時 2022-01-23 17:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 425 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 59,264 KB
最終ジャッジ日時 2024-05-07 05:39:25
合計ジャッジ時間 3,229 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
58,368 KB
testcase_01 AC 49 ms
58,112 KB
testcase_02 AC 49 ms
58,496 KB
testcase_03 AC 50 ms
58,496 KB
testcase_04 AC 50 ms
59,264 KB
testcase_05 AC 51 ms
58,240 KB
testcase_06 AC 49 ms
58,240 KB
testcase_07 AC 52 ms
58,368 KB
testcase_08 AC 49 ms
58,240 KB
testcase_09 AC 49 ms
58,624 KB
testcase_10 AC 51 ms
58,496 KB
testcase_11 AC 51 ms
58,624 KB
testcase_12 AC 50 ms
58,624 KB
testcase_13 AC 50 ms
58,624 KB
testcase_14 AC 49 ms
58,880 KB
testcase_15 AC 49 ms
58,496 KB
testcase_16 AC 49 ms
58,752 KB
testcase_17 AC 50 ms
58,752 KB
testcase_18 AC 52 ms
58,496 KB
testcase_19 AC 49 ms
58,112 KB
testcase_20 AC 49 ms
58,496 KB
testcase_21 AC 49 ms
58,368 KB
testcase_22 AC 52 ms
59,008 KB
testcase_23 AC 42 ms
52,096 KB
testcase_24 AC 42 ms
52,352 KB
testcase_25 AC 42 ms
52,352 KB
testcase_26 AC 42 ms
52,224 KB
testcase_27 AC 52 ms
58,752 KB
testcase_28 AC 43 ms
51,712 KB
testcase_29 AC 50 ms
58,752 KB
testcase_30 AC 44 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

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