#C4423. Sort and Repeat Elements
Sort and Repeat Elements
Sort and Repeat Elements
Given an array of integers, first sort the array in non-decreasing order. Then, for each element in the sorted array, output the element repeated a number of times equal to its 1-based index in that sorted order. Formally, if the sorted array is \(a_1, a_2, \ldots, a_n\), then the output should consist of \(a_1\) repeated once, \(a_2\) repeated twice, and so on, with a single space separating each number.
inputFormat
A single line read from standard input containing space-separated integers. The line may be empty, indicating an empty list.
outputFormat
A single line to standard output containing the transformed sequence of integers separated by a single space.## sample
4 2 1 3
1 2 2 3 3 3 4 4 4 4