結果

問題 No.324 落ちてた閉路グラフ
ユーザー ああいいああいい
提出日時 2022-01-28 14:14:38
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 681 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 846,788 KB
最終ジャッジ日時 2023-08-28 11:28:37
合計ジャッジ時間 7,353 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,336 KB
testcase_01 AC 73 ms
71,404 KB
testcase_02 AC 78 ms
71,212 KB
testcase_03 AC 71 ms
71,220 KB
testcase_04 MLE -
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
w = list(map(int,input().split()))

inf = -10 ** 8
dp1 = [[[inf] * 2 for _ in range(m+1)] for _ in range(n)]
dp1[0][1][1] = 0
dp2 = [[[inf] * 2 for _ in range(m+1)] for _ in range(n)]
dp2[0][0][0] = 0
for i in range(n-1):
    for j in range(m+1):
        dp1[i+1][j][0] = max(dp1[i][j][0],dp1[i][j][1])
        dp2[i+1][j][0] = max(dp2[i][j][0],dp2[i][j][1])
        if j > 0:
            dp1[i+1][j][1] = max(dp1[i][j-1][1] + w[i],dp1[i][j-1][0])
            dp2[i+1][j][1] = max(dp2[i][j-1][1] + w[i],dp2[i][j-1][0])
                             
dp1[-1][m][1] += w[-1]
ans = max(dp1[-1][m][1],dp1[-1][m][0],dp2[-1][m][0],dp2[-1][m][1])
print(ans)
0