結果

問題 No.37 遊園地のアトラクション
ユーザー tnodinotnodino
提出日時 2022-02-16 05:43:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 87,592 KB
最終ジャッジ日時 2023-09-11 17:07:04
合計ジャッジ時間 4,971 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
75,896 KB
testcase_01 AC 84 ms
75,768 KB
testcase_02 AC 94 ms
75,888 KB
testcase_03 AC 99 ms
75,796 KB
testcase_04 AC 93 ms
75,828 KB
testcase_05 AC 93 ms
75,860 KB
testcase_06 AC 90 ms
75,772 KB
testcase_07 AC 121 ms
84,764 KB
testcase_08 AC 87 ms
75,844 KB
testcase_09 AC 86 ms
75,876 KB
testcase_10 AC 106 ms
75,780 KB
testcase_11 AC 103 ms
75,864 KB
testcase_12 AC 92 ms
75,844 KB
testcase_13 AC 92 ms
75,764 KB
testcase_14 AC 88 ms
75,748 KB
testcase_15 AC 93 ms
75,900 KB
testcase_16 AC 98 ms
75,808 KB
testcase_17 AC 95 ms
75,904 KB
testcase_18 AC 119 ms
84,336 KB
testcase_19 AC 87 ms
75,936 KB
testcase_20 AC 94 ms
75,836 KB
testcase_21 AC 85 ms
75,836 KB
testcase_22 AC 126 ms
87,592 KB
testcase_23 AC 72 ms
71,336 KB
testcase_24 AC 73 ms
71,064 KB
testcase_25 AC 73 ms
71,204 KB
testcase_26 AC 72 ms
71,316 KB
testcase_27 AC 91 ms
75,700 KB
testcase_28 AC 81 ms
75,864 KB
testcase_29 AC 89 ms
75,808 KB
testcase_30 AC 72 ms
70,960 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:
        c.append(c[i])
        v.append(x)
        x //= 2
N = len(v)
DP = [[0] * (T+10) for _ in range(N+10)]
for i in range(N):
    for j in range(T+1):
        DP[i+1][j] = max(DP[i][j], DP[i+1][j])
        DP[i][j+1] = max(DP[i][j], DP[i][j+1])
        if j - c[i] >= 0:
            DP[i+1][j] = max(DP[i][j-c[i]] + v[i], DP[i+1][j])
print(DP[N][T])
0