結果

問題 No.324 落ちてた閉路グラフ
ユーザー TawaraTawara
提出日時 2015-12-17 03:07:24
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,966 ms / 5,000 ms
コード長 397 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 76,444 KB
実行使用メモリ 121,480 KB
最終ジャッジ日時 2024-04-27 15:59:54
合計ジャッジ時間 19,426 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
74,924 KB
testcase_01 AC 78 ms
74,912 KB
testcase_02 AC 77 ms
75,004 KB
testcase_03 AC 77 ms
74,888 KB
testcase_04 AC 1,908 ms
121,480 KB
testcase_05 AC 203 ms
77,600 KB
testcase_06 AC 1,932 ms
113,920 KB
testcase_07 AC 800 ms
82,720 KB
testcase_08 AC 1,966 ms
115,880 KB
testcase_09 AC 1,108 ms
87,448 KB
testcase_10 AC 1,964 ms
116,264 KB
testcase_11 AC 1,123 ms
87,432 KB
testcase_12 AC 80 ms
76,356 KB
testcase_13 AC 89 ms
77,732 KB
testcase_14 AC 78 ms
76,208 KB
testcase_15 AC 88 ms
77,748 KB
testcase_16 AC 74 ms
75,020 KB
testcase_17 AC 76 ms
75,632 KB
testcase_18 AC 77 ms
75,324 KB
testcase_19 AC 78 ms
75,044 KB
testcase_20 AC 76 ms
74,924 KB
testcase_21 AC 76 ms
75,208 KB
testcase_22 AC 77 ms
75,172 KB
testcase_23 AC 76 ms
74,888 KB
testcase_24 AC 76 ms
74,908 KB
testcase_25 AC 74 ms
75,016 KB
testcase_26 AC 74 ms
75,532 KB
testcase_27 AC 76 ms
75,052 KB
testcase_28 AC 75 ms
75,276 KB
testcase_29 AC 77 ms
75,308 KB
testcase_30 AC 75 ms
75,280 KB
testcase_31 AC 76 ms
75,184 KB
testcase_32 AC 439 ms
79,000 KB
testcase_33 AC 1,415 ms
98,936 KB
testcase_34 AC 1,523 ms
106,648 KB
testcase_35 AC 95 ms
77,432 KB
testcase_36 AC 609 ms
81,168 KB
testcase_37 AC 90 ms
77,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 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+w[n-1]*h*s for(k,h),v in D.iteritems())
print max(f(0),f(1))
0