QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 512 MB Puntuación total: 100

#8158. Jungle Clearing II

Estadísticas

Zayin is a wizard who fights monsters. This time, he is facing $n$ monsters standing in a row, where the $i$-th monster has $a_i$ health points.

Zayin knows many suppressed spells. In this battle, he decides to use a spell called "Lightning Combo" to defeat all the monsters at once. Let's see how this spell works:

  • First, Zayin chooses a monster $i$ ($1 \le i \le n$) and an initial spell power $x$.
  • Then, the spell first hits monster $i$. Subsequently, for all targets other than the first one, Zayin can choose a monster that has not been hit by the spell yet and is adjacent to one of the monsters that has already been hit.
  • The first target monster hit receives $x$ damage, the second target monster receives $x-1$ damage, the third receives $x-2$ damage, and so on. It is easy to see that each monster will be hit exactly once.

If a monster receives damage no less than its health points, it is considered dead.

Zayin wants to demonstrate his ability as a high-level wizard, so he hopes to use the minimum initial power $x$ such that he can kill all monsters using the spell exactly once.

You need to find the minimum initial power required and provide a valid sequence. If there are multiple different solutions, any one of them is acceptable.

Input

The first line contains two integers $d$ and $n$, representing the test case number and the number of monsters.

The next line contains $n$ integers, where the $i$-th integer $a_i$ represents the health of the $i$-th monster.

Output

The first line outputs an integer $x$, representing the minimum initial power.

The second line outputs $n$ space-separated indices $monster_i$ ($1 \le i \le n$), where $monster_i$ represents the $i$-th target monster hit.

Constraints

For all test data, it is guaranteed that $1 \le n \le 5 \times 10^6$ and $1 \le a_i \le 10^9$.

Test Case Number $n \le$
1 10
2 20
3 500
4 5000
5 $5 \times 10^4$
6, 7 $5 \times 10^5$
8, 9, 10 $5 \times 10^6$

Examples

Input 1

1 10
19 9 12 5 10 7 16 15 17 12

Output 1

25
1 2 3 4 5 6 7 8 9 10

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.