#P16902. [CCO 2026] Melborp
[CCO 2026] Melborp
Problem Description
Seta is creating problems for the CCO! She came up with the following problem:
Given an array whose values are in the range , define to be the number of pairs such that and $A[i] = \min(A[\ell], A[\ell + 1], \ldots, A[r - 1], A[r])$.
Print the array .
However, the day before the CCO, Seta’s computer crashed, and she was only able to recover the output files. Given the output array , can you write a program to reconstruct the input array ?
Seta reminds you that the array is not necessarily unique, and she will accept any valid array.
Input Format
The first line of input will contain a single integer, . The second line of input will contain space-separated integers ().
Output Format
Output space-separated integers, the array , where . It is guaranteed that there will always exist at least one valid array .
If there is more than one valid array, you may output any valid array. In particular, even if the original array is a permutation, your answer does not have to be a permutation.
3
3 1 2
1 3 2
2
2 2
1 1
3
1 4 1
2 1 3
Hint
Explanation of Output for Sample Input
- The subarrays , , have minimum . There are such subarrays.
- The subarray has minimum . There is such subarray.
- The subarrays and have minimum . There are such subarrays.
Explanation of Output for Sample Input
Note that would also be accepted by the judge.
The following table shows how the available marks are distributed:
| Marks Awarded | Bounds on | Additional Constraints |
|---|---|---|
| marks | None. | |
| marks | The original array is a permutation. | |
| marks | ||
| ^ | None. | |
| The original array is a permutation. | ||
| ^ | None. |