結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
76,616 KB
testcase_01 AC 74 ms
76,592 KB
testcase_02 AC 74 ms
76,432 KB
testcase_03 AC 73 ms
76,496 KB
testcase_04 AC 1,897 ms
123,264 KB
testcase_05 AC 204 ms
79,488 KB
testcase_06 AC 1,877 ms
115,492 KB
testcase_07 AC 797 ms
84,964 KB
testcase_08 AC 1,968 ms
117,632 KB
testcase_09 AC 1,111 ms
89,340 KB
testcase_10 AC 1,972 ms
118,280 KB
testcase_11 AC 1,118 ms
89,144 KB
testcase_12 RE -
testcase_13 AC 87 ms
79,268 KB
testcase_14 RE -
testcase_15 AC 86 ms
79,380 KB
testcase_16 RE -
testcase_17 AC 73 ms
76,404 KB
testcase_18 AC 74 ms
76,304 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 73 ms
76,604 KB
testcase_22 RE -
testcase_23 AC 74 ms
76,552 KB
testcase_24 RE -
testcase_25 AC 73 ms
76,516 KB
testcase_26 AC 75 ms
76,512 KB
testcase_27 AC 73 ms
76,508 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 74 ms
76,324 KB
testcase_31 AC 74 ms
76,420 KB
testcase_32 AC 444 ms
80,704 KB
testcase_33 AC 1,405 ms
101,032 KB
testcase_34 AC 1,518 ms
107,892 KB
testcase_35 AC 95 ms
79,200 KB
testcase_36 AC 616 ms
83,232 KB
testcase_37 AC 88 ms
79,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,raw_input().split())
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