結果

問題 No.324 落ちてた閉路グラフ
ユーザー TawaraTawara
提出日時 2015-12-17 11:08:10
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 353 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 6,544 KB
実行使用メモリ 11,152 KB
最終ジャッジ日時 2023-10-14 12:30:17
合計ジャッジ時間 7,786 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,944 KB
testcase_01 AC 9 ms
5,972 KB
testcase_02 AC 9 ms
5,860 KB
testcase_03 AC 9 ms
5,928 KB
testcase_04 TLE -
testcase_05 -- -
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 #

I=lambda:map(int,raw_input().split());n,m=I();w=I()
def f(s):
	D={(m-s,s):0}
	for i in xrange(n-1):
		T={}
		for (k,h),v in D.iteritems():
			for l in xrange(2):
				if 0<=k-l<n-1-i:
					nk=(k-l,l);nv=v+w[i]*h*l
					if nk not in T or T[nk]<nv:T[nk]=nv
		D=T
	return max(v+h*s*w[n-1]for(k,h),v in D.items())
print[[max(f(0),f(1)),sum(w)][m==n],0][m==0]
0