Early Orders
InterviewTime limit4sMemory limit1024 MB
Given a sequence where every value from 1 to k appears at least once, find the lexicographically smallest subsequence that contains each of those k values exactly once.
Problem
You are given a list of integers and a number . Every integer from to appears in the list at least once.
Find the lexicographically smallest subsequence of that contains each integer from to exactly once.
Input
The first line contains two integers and , with . The following lines each contain an integer with .
Output
Print on one line, separated by spaces, the lexicographically smallest subsequence of that contains each integer from to exactly once.