#K68222. Categorize Items by Expiration Durations
Categorize Items by Expiration Durations
Categorize Items by Expiration Durations
In this problem, you are given a list of items stored in a warehouse along with their expiration durations. Your task is to group these items based on their expiration durations and report the number of distinct expiration groups as well as the counts of items in each group.
More formally, if you have (n) items with expiration durations (d_1, d_2, \dots, d_n), you need to calculate the frequency of each unique expiration duration. Then, output the total number of unique durations followed by each duration and its corresponding count in ascending order of the duration.
inputFormat
The first line of the input contains a single integer (n) (the number of items).
The second line contains (n) space-separated integers representing the expiration durations of the items.
outputFormat
Output the number of unique expiration groups on the first line. Then, for each unique expiration duration, output a line with two integers: the expiration duration and the count of items with that duration. The groups must be listed in ascending order based on the expiration duration.## sample
5
2 2 2 2 2
1
2 5
</p>