結果

問題 No.258 回転寿司(2)
ユーザー 双六双六
提出日時 2020-08-11 03:19:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 905 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 55,552 KB
最終ジャッジ日時 2024-04-17 16:19:16
合計ジャッジ時間 7,741 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
55,168 KB
testcase_01 WA -
testcase_02 AC 53 ms
54,144 KB
testcase_03 AC 50 ms
54,272 KB
testcase_04 AC 51 ms
54,564 KB
testcase_05 WA -
testcase_06 AC 53 ms
55,040 KB
testcase_07 AC 51 ms
53,760 KB
testcase_08 WA -
testcase_09 AC 51 ms
54,144 KB
testcase_10 AC 50 ms
53,888 KB
testcase_11 AC 52 ms
54,272 KB
testcase_12 WA -
testcase_13 AC 51 ms
54,272 KB
testcase_14 AC 53 ms
55,040 KB
testcase_15 WA -
testcase_16 AC 51 ms
54,272 KB
testcase_17 AC 51 ms
54,272 KB
testcase_18 AC 53 ms
55,552 KB
testcase_19 WA -
testcase_20 AC 53 ms
54,400 KB
testcase_21 WA -
testcase_22 AC 50 ms
53,632 KB
testcase_23 AC 51 ms
53,820 KB
testcase_24 AC 51 ms
53,888 KB
testcase_25 AC 50 ms
53,632 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 50 ms
53,632 KB
testcase_47 AC 52 ms
54,912 KB
testcase_48 AC 50 ms
54,144 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 49 ms
54,144 KB
testcase_54 AC 51 ms
54,400 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	DP = [[0, 0] for i in range(N + 1)]
	pre = [[None, None] for i in range(N + 1)]
	for i in range(N):
		# 食べる推移
		DP[i + 1][1] = DP[i][0] + A[i]
		pre[i + 1][1] = 0

		# 食べない推移
		if DP[i][0] > DP[i][1]:
			DP[i + 1][0] = DP[i][0]
			pre[i + 1][0] = 0
		else:
			DP[i + 1][0] = DP[i][1]
			pre[i + 1][0] = 1

	# print(DP)
	# print(pre)
	ans = None
	anslist = []
	if DP[-1][1] > DP[-1][0]:
		ans = DP[-1][1]
		anslist.append(N)
		itr = 1
		for i in range(N, 1, -1):
			if pre[i][itr] == 1:
				anslist.append(i - 1)
				itr = 1
			else:
				itr = 0

	print(ans)
	print(*anslist[::-1])


if __name__ == '__main__':
	main()
0