You are given a list of N integers which may contain duplicate values. Your task is to analyze this list and produce a report containing two key pieces of information:
The first line of input contains an integer 'N', the number of elements in the list.
The second line contains 'N' space-separated integers, representing the list of numbers.
The first line of output must be a single integer representing the count of unique elements.
The second line of output must contain the unique elements, sorted in non-decreasing order and separated by single spaces.
The most efficient way to solve this is to use a data structure that automatically handles uniqueness, such as a Set or a Hash Set.
6
1 22 11 22 5 6
5
1 5 6 11 22
The unique elements in the list `{1, 22, 11, 22, 5, 6}` are `{1, 5, 6, 11, 22}`.
The count of these unique elements is 5.
When sorted, the list of unique elements is `{1, 5, 6, 11, 22}`.
5
5 4 3 2 1
5
1 2 3 4 5
All elements are already unique. The count is 5.
The sorted list of unique elements is `{1, 2, 3, 4, 5}`.
The expected time complexity is O(N logN).
1 <= N <= 10^5
-10^9 <= list element <= 10^9
Time limit: 1 sec