QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB

#23155. 달리기

Statistics

Runners in a long-distance race have passed the turning point. Each runner has a distinct integer ability; a larger value means a stronger runner. A runner can overtake any runner ahead whose ability is smaller, but cannot overtake a stronger runner.

Given the abilities in current race order, from front to back, find the best rank each runner can achieve.

For example, abilities $2,8,10,7,1,9,4,15$ give best ranks $1,1,1,3,5,2,5,1$. The fourth runner, with ability $7$, can pass the runner with ability $2$ but cannot pass those with abilities $8$ and $10$, so their best rank is $3$.

Input

The first line contains $N$ ($3 \le N \le 500000$). Each of the next $N$ lines contains one runner's ability, in current race order. Abilities are distinct integers between $1$ and $10^9$ inclusive.

Output

Print $N$ lines in input order, giving each runner's best rank. Rank 1 is first place.

Example

Input:

8
2
8
10
7
1
9
4
15

Output:

1
1
1
3
5
2
5
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.