結果

問題 No.324 落ちてた閉路グラフ
ユーザー ayame_pyayame_py
提出日時 2015-12-27 04:39:22
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 77,476 KB
実行使用メモリ 356,960 KB
最終ジャッジ日時 2023-10-19 11:11:19
合計ジャッジ時間 13,708 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,240 KB
testcase_01 AC 74 ms
76,240 KB
testcase_02 AC 77 ms
76,240 KB
testcase_03 AC 74 ms
76,240 KB
testcase_04 AC 568 ms
188,556 KB
testcase_05 AC 1,367 ms
356,960 KB
testcase_06 WA -
testcase_07 AC 1,399 ms
332,852 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 374 ms
119,416 KB
testcase_12 RE -
testcase_13 AC 98 ms
79,248 KB
testcase_14 AC 217 ms
97,912 KB
testcase_15 AC 325 ms
119,436 KB
testcase_16 RE -
testcase_17 AC 75 ms
76,240 KB
testcase_18 AC 75 ms
76,240 KB
testcase_19 AC 74 ms
76,240 KB
testcase_20 RE -
testcase_21 WA -
testcase_22 AC 74 ms
76,240 KB
testcase_23 AC 75 ms
76,240 KB
testcase_24 RE -
testcase_25 AC 75 ms
76,240 KB
testcase_26 AC 75 ms
76,240 KB
testcase_27 AC 75 ms
76,240 KB
testcase_28 AC 75 ms
76,240 KB
testcase_29 RE -
testcase_30 AC 75 ms
76,240 KB
testcase_31 AC 74 ms
76,240 KB
testcase_32 AC 1,484 ms
348,276 KB
testcase_33 AC 1,286 ms
302,800 KB
testcase_34 AC 584 ms
166,056 KB
testcase_35 AC 105 ms
79,820 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8
n,m=map(int,raw_input().split())
w=map(int,raw_input().split())
# dp[最初に頂点を選んだか][直前の頂点を選んだか][現在の頂点番号][選択済みの頂点数]
dp=[[[[-int(1e10+7) for l in xrange(m+1)] 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][1][n-1][m])
a=max(a,dp[1][1][n-1][m]+w[n-1])
print a
0