#K68817. Ranking Groups by Score Frequency
Ranking Groups by Score Frequency
Ranking Groups by Score Frequency
Given n participants and their respective scores, group the participants by identical scores and determine the number of participants in each group. Specifically, if a score appears k times, it constitutes a group of size k. The final output should be the sizes of these groups, sorted in decreasing order.
Mathematically, let \( s_1, s_2, \dots, s_n \) be the scores of the participants. For each unique score \( a \), let \( f(a) \) be the frequency of \( a \) in the list. The desired output is the sorted list of \( f(a) \) values in descending order.
For instance, if the input is 5
and the scores are [1000, 2000, 2000, 1000, 3000]
, then there are two scores (1000 and 2000) that occur twice and one score (3000) that occurs once. Thus, the output should be 2 2 1
.
inputFormat
The first line contains an integer n
representing the number of participants. The second line contains n
space-separated integers representing the scores of the participants.
outputFormat
Output a single line containing the sizes of the groups in decreasing order, separated by a space.
## sample1
1000
1
</p>