問題一覧 > 通常問題

No.258 Conveyor Belt Sushi (2)

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 205
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 710 / 自分の提出
問題文最終更新日: 2026-06-25 12:27:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder 1周年記念 復習コンテスト R2 (順位表) の他の問題:

Problem Statement

You are at a conveyor belt sushi restaurant.
N plates of sushi come along the belt in order. The deliciousness of each of the N plates of sushi is represented by \(V_i\).

You can take a plate of sushi when it comes in front of you, but under this restaurant's rules,
you cannot take plates consecutively.
Of course, you also cannot take sushi that has already passed in front of you.

Find the maximum total deliciousness you can obtain and the numbers of the plates you took (numbered starting from 1) in ascending order.
The sushi does not come around a second time.

Input

\(N \)
\(V_1\,V_2\,V_3 \ldots V_N \)

The first line contains the number of sushi plates \(N (1\le N \le 1000)\).
The second line contains the deliciousness of the $i$-th sushi \( V_i (1\le V_i \le 100,1 \le i \le N) \), separated by single spaces.

Output

Output the maximum total deliciousness you can obtain on the first line, and
the numbers of the plates you took (1-indexed), separated by spaces, on the second line.
If there are multiple answers, output any one of them.
If there is no answer at all, you may eat whatever sushi you like.

Sample

Sample 1
Input
4
1 2 3 4
Output
6
2 4

The ways to take sushi include taking the "1st and 3rd" sushi, taking the "1st and 4th" sushi, or taking the "2nd and 4th" sushi,
and taking the 2nd and 4th sushi gives the maximum deliciousness.

Sample 2
Input
4
5 4 4 9
Output
14
1 4

Taking the 1st sushi and the 4th sushi gives the maximum total deliciousness.

Sample 3
Input
7
1 2 9 10 1 1 4
Output
16
2 4 7

Taking 2, 10, 4 gives the maximum of 16.
You must deliberately skip the 1 at position 6 after the 10.

Sample 4
Input
1
100
Output
100
1

There may be only one plate.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。