QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 2048 MB Puntuación total: 100

#5719. 完美洗牌

Estadísticas

给定一个整数列表 $x_1, x_2, \dots, x_n$ 和一个数字 $k$。保证 $1$ 到 $k$ 中的每个整数在列表中至少出现一次。

请找出 $x$ 的字典序最小的子序列,该子序列恰好包含从 $1$ 到 $k$ 的每个整数各一次。

输入格式

第一行包含两个整数 $n$ 和 $k$,其中 $1 \le k \le n \le 200\,000$。接下来的 $n$ 行,每行包含一个整数 $x_i$,满足 $1 \le x_i \le k$。

输出格式

在一行中输出字典序最小的子序列,要求该子序列包含从 $1$ 到 $k$ 的每个整数各一次,数字之间用空格分隔。

样例

输入格式 1

6 3
3
2
1
3
1
3

输出格式 1

2 1 3

输入格式 2

10 5
5
4
3
2
1
4
1
1
5
5

输出格式 2

3 2 1 4 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.