結果

問題 No.324 落ちてた閉路グラフ
ユーザー TawaraTawara
提出日時 2015-12-17 02:57:46
言語 PyPy2
(7.3.15)
結果
MLE  
実行時間 -
コード長 544 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 77,804 KB
実行使用メモリ 837,664 KB
最終ジャッジ日時 2023-10-14 12:15:22
合計ジャッジ時間 7,531 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
76,352 KB
testcase_01 AC 70 ms
76,584 KB
testcase_02 AC 70 ms
76,488 KB
testcase_03 AC 69 ms
76,120 KB
testcase_04 AC 1,723 ms
494,096 KB
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 #

MIN = -10**6
n,m = map(int,raw_input().split())
w = map(int,raw_input().split())
if m==0:print 0;quit()
if m==n:print sum(w);quit()
def solve(s):
	dp = [[[MIN]*2 for i in xrange(m+2)] for i in xrange(n)]
	dp[0][s][s] = 0
	for i in xrange(n-1):
		for j in xrange(max(s,i+m-s-n+1),min(i+s,m)+1):
			for k in xrange(2):
				if dp[i][j][k] == MIN:continue
				dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k])
				dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i][j][k]+w[i]*k)
	return max(dp[n-1][m][0],dp[n-1][m][1]+w[n-1]*s)
print max(solve(0), solve(1))
0