#K7886. Reconstruct Array Based on Frequency
Reconstruct Array Based on Frequency
Reconstruct Array Based on Frequency
You are given a list of non-negative integers. The integer at the \(i\)-th index represents the frequency of the number \(i+1\). Your task is to reconstruct the original array where each number \(i+1\) appears exactly its frequency times. The resulting array should be in non-decreasing order.
For example, if the input is [2, 1, 1], then the output should be [1, 1, 2, 3].
inputFormat
The input is given via standard input (stdin). The first line contains a single integer \(n\), representing the length of the frequency list. The second line contains \(n\) space-separated non-negative integers; the \(i\)-th integer indicates the frequency of \(i+1\).
outputFormat
Output the reconstructed array in non-decreasing order as a single line of space-separated integers via standard output (stdout).
## sample3
2 1 1
1 1 2 3