#t76. 初级桶排序
初级桶排序
Beginner's Bucket Sort
Problem Description
Little J has finally learned about arrays, and he knows that he can use an array to sort a sequence of numbers!
Today he gives it a try, using an array to sort numbers. Can you do it too?
Input Format
The first line contains a positive integer .
The second line contains consecutive non-negative integers, each not greater than .
Output Format
One line: output the numbers sorted from smallest to largest, separated by single spaces. If a number appears multiple times, write it only once in the sorted result.
Sample Input 1
5
3 7 0 2 4
Sample Output 1
0 2 3 4 7
Sample Input 2
5
1 2 1 2 1
Sample Output 2
1 2
Bucket Sort
By observation we find that the consecutive non-negative integers (each ) are exactly suitable to be used as array indices.
So far we have only one way of using arrays:

a[i] = x; means the -th number is .
Now let's think: can we also use it the other way around?
c[x]=1; — what does that represent?
It means that appears time in array .
We call the array a "bucket", used to record how many times a number appears in another array.
We let start from and loop until the maximum value among the inputs; as long as is not , we output .
Special note: the size of the array depends on the maximum value among the inputs, and all input numbers must be natural numbers that can serve as array indices.