#d1404. 字典序最小
字典序最小
Lexicographically Smallest
Problem Description
Choose distinct numbers in order from a sequence of numbers, so that the numbers form the lexicographically smallest sequence.
Input Format
The first line contains two integers — the length of the sequence and the number of numbers to choose in order ().
The next lines: the -th line contains , the -th number of sequence , where . It is guaranteed that every number in appears at least once.
Output Format
Output numbers separated by spaces, representing the lexicographically smallest sequence (no trailing space after the last number).
Sample Input
6 3
3
2
1
3
1
3
Sample Output
2 1 3
Hint
The lexicographically smallest sequence you are looking for need not be contiguous in sequence .