結果

問題 No.37 遊園地のアトラクション
ユーザー 👑 colognecologne
提出日時 2022-01-23 17:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 425 bytes
コンパイル時間 484 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 75,744 KB
最終ジャッジ日時 2023-08-19 22:36:35
合計ジャッジ時間 4,839 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,500 KB
testcase_01 AC 77 ms
75,744 KB
testcase_02 AC 78 ms
75,560 KB
testcase_03 AC 80 ms
75,560 KB
testcase_04 AC 79 ms
75,328 KB
testcase_05 AC 81 ms
75,472 KB
testcase_06 AC 80 ms
75,512 KB
testcase_07 AC 81 ms
75,476 KB
testcase_08 AC 78 ms
75,644 KB
testcase_09 AC 79 ms
75,452 KB
testcase_10 AC 80 ms
75,628 KB
testcase_11 AC 82 ms
75,404 KB
testcase_12 AC 78 ms
75,580 KB
testcase_13 AC 79 ms
75,472 KB
testcase_14 AC 80 ms
75,404 KB
testcase_15 AC 79 ms
75,448 KB
testcase_16 AC 78 ms
75,584 KB
testcase_17 AC 79 ms
75,404 KB
testcase_18 AC 79 ms
75,616 KB
testcase_19 AC 80 ms
75,400 KB
testcase_20 AC 79 ms
75,372 KB
testcase_21 AC 79 ms
75,500 KB
testcase_22 AC 84 ms
75,452 KB
testcase_23 AC 71 ms
71,252 KB
testcase_24 AC 71 ms
71,288 KB
testcase_25 AC 74 ms
71,312 KB
testcase_26 AC 73 ms
71,188 KB
testcase_27 AC 74 ms
75,624 KB
testcase_28 AC 72 ms
71,284 KB
testcase_29 AC 76 ms
75,572 KB
testcase_30 AC 75 ms
71,488 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