QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 128 MB

#23155. 赛跑

통계

一场长跑比赛中的选手已经通过折返点。每名选手都有一个互不相同的整数能力值;能力值越大,选手越强。一名选手可以超越在自己前方且能力值更小的任何选手,但无法超越更强的选手。

给定按当前比赛顺序从前到后排列的选手能力值,求每名选手能够取得的最佳名次。

例如,能力值 $2,8,10,7,1,9,4,15$ 对应的最佳名次为 $1,1,1,3,5,2,5,1$。能力值为 $7$ 的第四名选手可以超越能力值为 $2$ 的选手,但无法超越能力值为 $8$ 和 $10$ 的选手,因此其最佳名次为 $3$。

输入格式

第一行包含 $N$($3 \le N \le 500000$)。接下来的 $N$ 行每行包含一名选手的能力值,按当前比赛顺序给出。能力值是 $1$ 到 $10^9$ 之间(含两端)互不相同的整数。

输出格式

按输入顺序输出 $N$ 行,每行给出对应选手能够取得的最佳名次。名次 1 表示第一名。

样例

输入格式 1

8
2
8
10
7
1
9
4
15

输出格式 1

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.