結果

問題 No.258 回転寿司(2)
ユーザー ayame_pyayame_py
提出日時 2015-10-20 14:34:18
言語 Python2
(2.7.18)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-24 11:13:18
合計ジャッジ時間 12,264 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 417 ms
8,448 KB
testcase_01 AC 418 ms
8,448 KB
testcase_02 AC 150 ms
7,296 KB
testcase_03 AC 9 ms
6,272 KB
testcase_04 AC 70 ms
6,912 KB
testcase_05 AC 78 ms
6,784 KB
testcase_06 AC 292 ms
8,192 KB
testcase_07 AC 34 ms
6,400 KB
testcase_08 AC 83 ms
6,912 KB
testcase_09 AC 39 ms
6,656 KB
testcase_10 AC 14 ms
6,528 KB
testcase_11 AC 48 ms
6,656 KB
testcase_12 AC 66 ms
6,656 KB
testcase_13 AC 30 ms
6,656 KB
testcase_14 AC 266 ms
7,808 KB
testcase_15 AC 36 ms
6,656 KB
testcase_16 AC 33 ms
6,784 KB
testcase_17 AC 33 ms
6,656 KB
testcase_18 AC 332 ms
8,192 KB
testcase_19 AC 9 ms
6,400 KB
testcase_20 AC 174 ms
7,296 KB
testcase_21 AC 278 ms
7,808 KB
testcase_22 AC 9 ms
6,272 KB
testcase_23 AC 10 ms
6,528 KB
testcase_24 AC 10 ms
6,272 KB
testcase_25 AC 9 ms
6,400 KB
testcase_26 AC 147 ms
7,296 KB
testcase_27 AC 38 ms
6,656 KB
testcase_28 AC 400 ms
8,576 KB
testcase_29 AC 53 ms
6,912 KB
testcase_30 AC 13 ms
6,400 KB
testcase_31 AC 13 ms
6,400 KB
testcase_32 AC 39 ms
6,784 KB
testcase_33 AC 213 ms
7,552 KB
testcase_34 AC 114 ms
7,040 KB
testcase_35 AC 95 ms
6,940 KB
testcase_36 AC 16 ms
6,528 KB
testcase_37 AC 14 ms
6,400 KB
testcase_38 AC 49 ms
6,784 KB
testcase_39 AC 47 ms
6,784 KB
testcase_40 AC 143 ms
7,168 KB
testcase_41 AC 219 ms
7,680 KB
testcase_42 AC 35 ms
6,784 KB
testcase_43 AC 22 ms
6,400 KB
testcase_44 AC 267 ms
7,808 KB
testcase_45 AC 165 ms
7,296 KB
testcase_46 AC 10 ms
6,528 KB
testcase_47 AC 178 ms
7,424 KB
testcase_48 AC 21 ms
6,528 KB
testcase_49 AC 39 ms
6,656 KB
testcase_50 AC 11 ms
6,400 KB
testcase_51 AC 133 ms
7,040 KB
testcase_52 AC 97 ms
6,944 KB
testcase_53 AC 14 ms
6,400 KB
testcase_54 AC 160 ms
7,296 KB
testcase_55 AC 416 ms
8,448 KB
testcase_56 AC 165 ms
7,424 KB
testcase_57 AC 18 ms
6,528 KB
testcase_58 AC 90 ms
7,040 KB
testcase_59 AC 346 ms
8,064 KB
testcase_60 AC 12 ms
6,400 KB
testcase_61 AC 211 ms
7,552 KB
testcase_62 AC 40 ms
6,784 KB
testcase_63 AC 140 ms
7,168 KB
testcase_64 AC 406 ms
8,448 KB
testcase_65 AC 158 ms
7,296 KB
testcase_66 AC 12 ms
6,528 KB
testcase_67 AC 241 ms
7,680 KB
testcase_68 AC 253 ms
7,808 KB
testcase_69 AC 192 ms
7,424 KB
testcase_70 AC 34 ms
6,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
N=input()
V=map(int,raw_input().split())
dp=[0 for _ in range(N)]
r=[[] for _ in range(N)]
if N == 1:
	print V[0]
	print 1
	sys.exit()
dp[0]=V[0]
r[0]=[1]
if V[0] < V[1]:
	dp[1] = V[1]
	r[1] = [2]
else:
	dp[1] = V[0]
	r[1] = [1]
for i in range(2,N):
	for j in range(0,i-1):
		if dp[j]+V[i] > dp[i]:
			dp[i]=dp[j]+V[i]
			r[i]=list(r[j])
			r[i].append(i+1)
	if dp[i] < dp[i-1]:
		dp[i]=dp[i-1]
		r[i]=r[i-1]

print dp[N-1]
print ' '.join(map(str,r[N-1])).rstrip(' ')
0