#K92047. Unique Shipments
Unique Shipments
Unique Shipments
You are given a list of shipment identifiers. Your task is to count the number of unique shipments and then list each unique shipment identifier along with its count. The list of shipment identifiers should be sorted in ascending order before counting.
Formally, given an integer ( n ) (the number of shipments) and a list of ( n ) integers representing the shipment identifiers, you need to output the total number of unique shipments, followed by each unique shipment identifier and its frequency.
For example, if the input is:
7 4 3 2 4 2 3 1
The output should be:
4 1 1 2 2 3 2 4 2
inputFormat
The first line contains a single integer ( n ) denoting the number of shipments. The second line contains ( n ) space-separated integers, where each integer represents a shipment identifier.
outputFormat
Output the number of unique shipments on the first line. Then, for each unique shipment identifier in ascending order, output a line containing two space-separated integers: the shipment identifier and its count.## sample
7
4 3 2 4 2 3 1
4
1 1
2 2
3 2
4 2
</p>