結果

問題 No.324 落ちてた閉路グラフ
ユーザー TawaraTawara
提出日時 2015-12-17 11:23:56
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,760 ms / 5,000 ms
コード長 361 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 76,048 KB
実行使用メモリ 121,752 KB
最終ジャッジ日時 2024-04-27 16:01:23
合計ジャッジ時間 16,079 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
74,900 KB
testcase_01 AC 74 ms
75,412 KB
testcase_02 AC 74 ms
75,008 KB
testcase_03 AC 68 ms
75,272 KB
testcase_04 AC 1,626 ms
121,752 KB
testcase_05 AC 182 ms
78,092 KB
testcase_06 AC 1,678 ms
113,812 KB
testcase_07 AC 687 ms
82,472 KB
testcase_08 AC 1,701 ms
115,844 KB
testcase_09 AC 961 ms
87,844 KB
testcase_10 AC 1,760 ms
116,144 KB
testcase_11 AC 992 ms
87,208 KB
testcase_12 AC 71 ms
76,192 KB
testcase_13 AC 82 ms
77,964 KB
testcase_14 AC 74 ms
75,940 KB
testcase_15 AC 81 ms
77,956 KB
testcase_16 AC 66 ms
75,028 KB
testcase_17 AC 69 ms
75,080 KB
testcase_18 AC 68 ms
75,008 KB
testcase_19 AC 67 ms
75,144 KB
testcase_20 AC 68 ms
75,428 KB
testcase_21 AC 70 ms
75,032 KB
testcase_22 AC 69 ms
75,524 KB
testcase_23 AC 65 ms
75,172 KB
testcase_24 AC 68 ms
74,908 KB
testcase_25 AC 68 ms
75,536 KB
testcase_26 AC 70 ms
75,016 KB
testcase_27 AC 71 ms
75,308 KB
testcase_28 AC 72 ms
74,916 KB
testcase_29 AC 74 ms
75,148 KB
testcase_30 AC 73 ms
75,456 KB
testcase_31 AC 70 ms
75,020 KB
testcase_32 AC 378 ms
78,640 KB
testcase_33 AC 1,230 ms
99,232 KB
testcase_34 AC 1,377 ms
106,408 KB
testcase_35 AC 87 ms
77,596 KB
testcase_36 AC 547 ms
80,940 KB
testcase_37 AC 82 ms
77,088 KB
権限があれば一括ダウンロードができます

ソースコード

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))if(n>m)*(m>0)else[0,sum(w)][m>0]
0