#C13522. Remove Duplicates and Sort Integers

    ID: 43070 Type: Default 1000ms 256MiB

Remove Duplicates and Sort Integers

Remove Duplicates and Sort Integers

Given a list of integers, your task is to remove all duplicate values and output the unique integers in ascending order.

The input is provided via stdin where the first line contains an integer \(n\) representing the number of integers, and the second line contains \(n\) space-separated integers. Your solution should run in \(O(n \log n)\) time complexity.

For example, if the input is "4\n3 1 4 2", then the output should be "1 2 3 4".

inputFormat

The input consists of two lines read from stdin:

  1. The first line contains a single integer \(n\) (\(0 \le n \le 10^5\)).
  2. The second line contains \(n\) space-separated integers. The integers can be negative or positive.

outputFormat

Output the unique integers sorted in ascending order, separated by a single space. If the list is empty, output nothing.

## sample
4
3 1 4 2
1 2 3 4

</p>