結果

問題 No.324 落ちてた閉路グラフ
ユーザー ayame_pyayame_py
提出日時 2015-12-27 04:57:07
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,325 ms / 5,000 ms
コード長 718 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 76,584 KB
実行使用メモリ 356,240 KB
最終ジャッジ日時 2024-04-27 16:06:13
合計ジャッジ時間 11,920 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
75,812 KB
testcase_01 AC 72 ms
75,788 KB
testcase_02 AC 70 ms
76,060 KB
testcase_03 AC 70 ms
75,396 KB
testcase_04 AC 485 ms
187,956 KB
testcase_05 AC 1,277 ms
356,240 KB
testcase_06 AC 534 ms
166,800 KB
testcase_07 AC 1,274 ms
332,192 KB
testcase_08 AC 555 ms
166,816 KB
testcase_09 AC 326 ms
118,776 KB
testcase_10 AC 493 ms
167,216 KB
testcase_11 AC 341 ms
119,172 KB
testcase_12 AC 84 ms
78,232 KB
testcase_13 AC 88 ms
78,880 KB
testcase_14 AC 197 ms
98,204 KB
testcase_15 AC 296 ms
119,048 KB
testcase_16 AC 70 ms
75,532 KB
testcase_17 AC 69 ms
75,452 KB
testcase_18 AC 69 ms
75,684 KB
testcase_19 AC 68 ms
75,548 KB
testcase_20 AC 68 ms
75,656 KB
testcase_21 AC 73 ms
75,448 KB
testcase_22 AC 68 ms
75,892 KB
testcase_23 AC 69 ms
75,460 KB
testcase_24 AC 68 ms
75,540 KB
testcase_25 AC 68 ms
75,532 KB
testcase_26 AC 70 ms
75,580 KB
testcase_27 AC 68 ms
75,944 KB
testcase_28 AC 68 ms
75,916 KB
testcase_29 AC 70 ms
75,440 KB
testcase_30 AC 68 ms
75,916 KB
testcase_31 AC 68 ms
75,416 KB
testcase_32 AC 1,325 ms
346,784 KB
testcase_33 AC 1,170 ms
301,828 KB
testcase_34 AC 548 ms
166,536 KB
testcase_35 AC 97 ms
79,116 KB
testcase_36 AC 188 ms
98,076 KB
testcase_37 AC 96 ms
78,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8
import sys
n,m=map(int,raw_input().split())
w=map(int,raw_input().split())
# dp[最初に頂点を選んだか][直前の頂点を選んだか][現在の頂点番号][選択済みの頂点数]
dp=[[[[-int(1e10+7) for l in xrange(m+2)] for k in xrange(n)] for j in xrange(2)] for i in xrange(2)]
dp[0][0][0][0]=0
dp[1][1][0][1]=0
a=-int(1e9+7)
for i in range(2):
	for k in range(n-1):
		for l in range(m+1):
			# 選択しない場合
			dp[i][0][k+1][l]=max(dp[i][0][k][l],dp[i][1][k][l])
			# 選択する場合
			if l: dp[i][1][k+1][l]=max(dp[i][0][k][l-1],dp[i][1][k][l-1]+w[k])

a=max(a,dp[1][0][n-1][m])
a=max(a,dp[0][0][n-1][m])
a=max(a,dp[0][1][n-1][m])
a=max(a,dp[1][1][n-1][m]+w[n-1])
print a
0