欢迎光临散文网 会员登陆 & 注册

CF 551A - GukiZ and Contest

2023-08-22 16:43 作者:您是打尖儿还是住店呢  | 我要投稿

Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest.


In total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from 1 to n. Let's denote the rating of i-th student as ai. After the contest ends, every student will end up with some positive integer position. GukiZ expects that his students will take places according to their ratings.


He thinks that each student will take place equal to . In particular, if student A has rating strictly lower then student B, A will get the strictly better position than B, and if two students have equal ratings, they will share the same position.


GukiZ would like you to reconstruct the results by following his expectations. Help him and determine the position after the end of the contest for each of his students if everything goes as expected.


Input

The first line contains integer n (1 ≤ n ≤ 2000), number of GukiZ's students.


The second line contains n numbers a1, a2, ... an (1 ≤ ai ≤ 2000) where ai is the rating of i-th student (1 ≤ i ≤ n).


Output

In a single line, print the position after the end of the contest for each of n students in the same order as they appear in the input

----------------------------

GukiZ 教授喜欢编程竞赛。 他特别喜欢在他准备的比赛中对学生进行评分。 

现在,他决定准备一场新的比赛。 总共有n名学生参加,在开始之前,每个人都有一些正整数评分。 学生的索引从 1 到 n。 我们将第 i 个学生的评分表示为 ai。 

比赛结束后,每个学生最终都会获得某个正整数的位置。 GukiZ 预计他的学生将根据他们的评分获得名次。 他认为每个学生都会取得平等的成绩。 特别是,如果学生 A 的评分严格低于学生 B,则 A 将获得比 B 严格更好的位置,如果两个学生的评分相同,他们将共享相同的位置。

GukiZ 希望你按照他的期望来重建结果。 如果一切按预期进行,请帮助他在比赛结束后为他的每个学生确定位置。

输入

第一行包含整数n(1 ≤ n ≤ 2000),GukiZ的学生人数。 第二行包含 n 个数字 a1, a2, ... an (1 ≤ ai ≤ 2000),其中 ai 是第 i 个学生的评分 (1 ≤ i ≤ n)。

输出

在一行中,按照输入中出现的顺序打印 n 个学生中每人比赛结束后的位置

input

3
1 3 3

output

3 1 1

input

5
3 5 3 4 5

output

4 1 4 3 1

利用二维数据排序处理,加2个变量每次去存储数据即可,下面是代码:


CF 551A - GukiZ and Contest的评论 (共 条)

分享到微博请遵守国家法律