You have a one-indexed array
You also decided on a value
- Choose an index
( , and swap with .
Please output the lexicographically smallest array that can be made if you choose the optimal value of
Input Specification
The first line will contain the integer
The next line will contain
Output Specification
Output the lexicographically smallest array that can be made if the optimal value of
Subtasks
Subtask 1 [12%]
Subtask 2 [27%]
Subtask 3 [61%]
Sample Input for Subtask 1
Copy
5
5 4 3 2 1
Sample Output for Subtask 1
Copy
1 2 3 4 5
Sample Input for Subtask 2
Copy
6
3 1 1 1 1 2
Sample Output for Subtask 2
Copy
1 1 1 1 3 2
Explanation for Sample for Subtask 2
One optimal value of
Sample Input for Subtask 3
Copy
11
5 1 2 1 2 1 2 1 1 2 100
Sample Output for Subtask 3
Copy
1 1 1 1 2 5 2 2 1 2 100
Comments