

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
以上 以下の整数からなる長さ の数列 があります。ここで、 以上 以下のどの整数も に 回以上登場します。
の長さ の(連続とは限らない)部分列であって が 回ずつ登場するもののうち、辞書順最小のものを答えてください。
制約
- 以上 以下のどの整数も に 回以上登場する。
- 入力中の値はすべて整数である。
入力
入力は以下の形式で標準入力から与えられる。
出力
求めるべき部分列を として、以下の形式で出力せよ。
入力例 1Copy
4 3 2 3 1 3
出力例 1Copy
2 1 3
の長さ の部分列であって が 回ずつ登場するものは と であり、このうち辞書順で小さいのは です。
入力例 2Copy
4 4 2 3 1 4
出力例 2Copy
2 3 1 4
入力例 3Copy
20 10 6 3 8 5 8 10 9 3 6 1 8 3 3 7 4 7 2 7 8 5
出力例 3Copy
3 5 8 10 9 6 1 4 2 7
Score : points
Problem Statement
We have a sequence of length consisting of integers between and . Here, every integer from to appears at least once in .
Among the length- subsequences of where each of appears once, find the lexicographically smallest one.
Constraints
- Every integer between and , inclusive, appears at least once in .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Let be the sought subsequence, and print it in the following format:
Sample Input 1Copy
4 3 2 3 1 3
Sample Output 1Copy
2 1 3
The length- subsequences of where each of appears once are and . The lexicographically smaller among them is .
Sample Input 2Copy
4 4 2 3 1 4
Sample Output 2Copy
2 3 1 4
Sample Input 3Copy
20 10 6 3 8 5 8 10 9 3 6 1 8 3 3 7 4 7 2 7 8 5
Sample Output 3Copy
3 5 8 10 9 6 1 4 2 7