CF 551A - GukiZ and Contest
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 教授喜歡編程競賽。 他特別喜歡在他準備的比賽中對學(xué)生進行評分。?
現(xiàn)在,他決定準備一場新的比賽。 總共有n名學(xué)生參加,在開始之前,每個人都有一些正整數(shù)評分。 學(xué)生的索引從 1 到 n。 我們將第 i 個學(xué)生的評分表示為 ai。?
比賽結(jié)束后,每個學(xué)生最終都會獲得某個正整數(shù)的位置。 GukiZ 預(yù)計他的學(xué)生將根據(jù)他們的評分獲得名次。 他認為每個學(xué)生都會取得平等的成績。 特別是,如果學(xué)生 A 的評分嚴格低于學(xué)生 B,則 A 將獲得比 B 嚴格更好的位置,如果兩個學(xué)生的評分相同,他們將共享相同的位置。
GukiZ 希望你按照他的期望來重建結(jié)果。 如果一切按預(yù)期進行,請幫助他在比賽結(jié)束后為他的每個學(xué)生確定位置。
輸入
第一行包含整數(shù)n(1?≤?n?≤?2000),GukiZ的學(xué)生人數(shù)。 第二行包含 n 個數(shù)字 a1,?a2,?... an (1?≤?ai?≤?2000),其中 ai 是第 i 個學(xué)生的評分 (1?≤?i?≤?n)。
輸出
在一行中,按照輸入中出現(xiàn)的順序打印 n 個學(xué)生中每人比賽結(jié)束后的位置
input
3
1 3 3
output
3 1 1
input
5
3 5 3 4 5
output
4 1 4 3 1
利用二維數(shù)據(jù)排序處理,加2個變量每次去存儲數(shù)據(jù)即可,下面是代碼: