P26679 [AtCoder] Cheerful Enchantress
提高-
题目描述

Problem Description

Iroha-chan, who is always cheerful, has $N$ friends who are monsters. The height of the $i$-th friend (where $1 \leq i \leq N$) is $H_i$.

Iroha-chan wants to remember not only their names but also their heights to avoid forgetting her friends due to their increasing number. However, since her friends are monsters, some of them are extremely tall while others are very short. Therefore, Iroha-chan wants to replace their heights with as small numbers as possible while maintaining the height order.

Specifically, for any pair of integers $(i, j)$, she wants to construct a sequence of positive integers $X_1, X_2, \cdots, X_N$ that satisfies $H_i \leq H_j \Leftrightarrow X_i \leq X_j$ and has the smallest possible maximum value.

Please help Iroha-chan replace the heights of her $N$ friends.

Input Format

The input is given in the following format:

$N$ $H_1$ $H_2$ $\vdots$ $H_N$

Output Format

Output the replaced heights as positive integers from the 1st to the $N$-th friend in $N$ lines.

Sample Input and Output

Sample Input #1

3
10
20
30

Sample Output #1

1
2
3

Sample Input #2

5
10
20
10
30
55

Sample Output #2

1
2
1
3
4

Sample Input #3

2
10000
10000

Sample Output #3

1
1

Notes/Hints

Constraints

  • All inputs are integers.
  • $1 \leq N \leq 10^5$
  • $1 \leq H_i \leq 10^9$

Explanation

Explanation

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 10 20 30
样例输出
1 2 3