結果

問題 No.324 落ちてた閉路グラフ
ユーザー TawaraTawara
提出日時 2015-12-17 01:52:14
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 525 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 77,604 KB
実行使用メモリ 123,356 KB
最終ジャッジ日時 2023-10-14 12:01:21
合計ジャッジ時間 17,624 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
76,516 KB
testcase_01 AC 72 ms
76,224 KB
testcase_02 AC 69 ms
76,568 KB
testcase_03 AC 69 ms
76,508 KB
testcase_04 AC 1,607 ms
123,356 KB
testcase_05 AC 180 ms
79,648 KB
testcase_06 AC 1,670 ms
115,364 KB
testcase_07 AC 687 ms
84,852 KB
testcase_08 AC 1,709 ms
117,736 KB
testcase_09 AC 978 ms
89,548 KB
testcase_10 AC 1,702 ms
118,052 KB
testcase_11 AC 1,003 ms
89,096 KB
testcase_12 AC 67 ms
76,180 KB
testcase_13 AC 79 ms
79,400 KB
testcase_14 RE -
testcase_15 AC 78 ms
79,264 KB
testcase_16 AC 68 ms
76,380 KB
testcase_17 AC 66 ms
76,620 KB
testcase_18 AC 68 ms
76,448 KB
testcase_19 RE -
testcase_20 AC 66 ms
76,308 KB
testcase_21 AC 65 ms
76,532 KB
testcase_22 RE -
testcase_23 AC 66 ms
76,512 KB
testcase_24 AC 67 ms
76,700 KB
testcase_25 AC 69 ms
76,352 KB
testcase_26 AC 69 ms
76,396 KB
testcase_27 AC 69 ms
76,444 KB
testcase_28 RE -
testcase_29 AC 67 ms
76,292 KB
testcase_30 AC 69 ms
76,384 KB
testcase_31 AC 70 ms
76,300 KB
testcase_32 AC 380 ms
80,692 KB
testcase_33 AC 1,231 ms
101,356 KB
testcase_34 AC 1,314 ms
108,004 KB
testcase_35 AC 84 ms
79,324 KB
testcase_36 AC 529 ms
83,184 KB
testcase_37 AC 78 ms
79,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,raw_input().split())
if n <= 1 or m == 0:
	print 0
	quit()
w = map(int,raw_input().split())
def solve(start):
	dp = {(m-start,start):0}
	for i in xrange(n-1):
		tmp_dp = dict()
		for (k,h),v in dp.iteritems():
			for nxt in xrange(2):
				if 0 <= k-nxt < n-1-i:
					nk = (k-nxt,nxt)
					nv =  v + (w[i] if h*nxt == 1 else 0)
					if nk not in tmp_dp or tmp_dp[nk] < nv:
						tmp_dp[nk] = nv
		dp = tmp_dp
	return max(v + (w[n-1] if h*start else 0) for (k,h),v in dp.iteritems())
print max(solve(0), solve(1))
0