QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 512 MB 満点: 100

#17599. K-TI

統計

给定一个数列和一个自然数 $K$。

我们在数列中寻找位置为 $K$ 的倍数的数中的最大值,其中数列的位置从 $0$ 开始计数。换句话说,我们在位置 $0, K, 2K, 3K, \dots$ 处寻找最大值。如果存在多个相同的最大值,我们选择位置最靠前的一个。将找到的数从数列中删除,其后的数会向左移动一个位置,即改变它们的位置以填补产生的“空缺”。

重复上述步骤,直到数列中没有数字为止。请编写一个程序来完成此操作。

输入格式

第一行包含自然数 $N$ 和 $K$ ($2 \le K \le N \le 100\,000$)。

下一行包含 $N$ 个自然数,其值在区间 $[1, N]$ 内,构成了给定的数列,按从第 $0$ 个到第 $(N-1)$ 个的顺序排列。

输出格式

输出 $N$ 个自然数,其中第 $i$ 个输出的数等于第 $i$ 步中删除的数。

子任务

子任务 分值 附加限制
1 7 $N \le 1000$
2 25 $K = 2$
3 23 $K \le 10$
4 25 $100 \le K \le N$
5 20 无附加限制

样例

输入格式 1

10 2
2 3 1 9 10 4 5 6 1 5

输出格式 1

10
6
4
5
2
9
3
5
1
1

输入格式 2

10 3
2 3 1 9 10 4 5 6 1 5

输出格式 2

9
10
4
5
6
2
5
3
1
1

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.