QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100

#11733. 最长递增子序列

統計

给定 $f_1, f_2, \dots, f_n$,求一个 $1, 2, \dots, n$ 的排列 $p_1, p_2, \dots, p_n$,使得对于每个 $i$,以 $p_i$ 结尾的最长严格递增子序列的长度恰好为 $f_i$。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^5$)。 第二行包含 $n$ 个整数 $f_1, f_2, \dots, f_n$ ($1 \le f_i \le n$)。保证对于给定的输入,至少存在一个这样的排列 $p_1, p_2, \dots, p_n$。

输出格式

在第一行输出 $n$ 个整数 $p_1, p_2, \dots, p_n$。这些数字必须构成 $1, 2, \dots, n$ 的一个排列。如果存在多个可能的答案,输出其中任意一个即可。

样例

样例输入 1

7
1 1 1 1 1 1 1

样例输出 1

7 6 5 4 3 2 1

样例输入 2

7
1 2 3 2 4 4 3

样例输出 2

1 3 5 2 7 6 4

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.