

実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
1 から N までの番号が付けられた N 人の人がとあるコンテストに参加し、人 i\ (1\leq i\leq N) の 得点 は P_i でした。
このコンテストでは、以下の手順によって N 人それぞれの 順位 が定まります。
- 変数 r を用意し、r=1 と初期化する。最初、N 人の順位はすべて未確定である。
- N 人全員の順位が確定するまで以下の操作を繰り返す。
- 順位が未確定である人の中での得点の最大値を x とし、得点が x である人の数を k とおく。得点が x である k 人すべての順位を r 位と確定させたのち、r に k を足す。
N 人それぞれの順位を出力してください。
制約
- 1\leq N \leq 100
- 1\leq P_i\leq 100
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N P_1 P_2 \dots P_N
出力
N 行出力せよ。 i\ (1\leq i \leq N) 行目には、人 i の順位を整数として出力せよ。
入力例 1
4 3 12 9 9
出力例 1
4 1 2 2
以下のようにして N\ (=4) 人それぞれの順位が定まります。
- 変数 r を用意し、r=1 と初期化する。最初、4 人の順位はすべて未確定である。
- 現時点で順位が未確定なのは人 1,2,3,4 であり、その中での得点の最大値は P_2\ (=12) である。よって、人 2 の順位を r\ (=1) 位と確定させたのち、r に 1 を足して r=2 とする。
- 現時点で順位が未確定なのは人 1,3,4 であり、その中での得点の最大値は P_3=P_4\ (=9) である。よって、人 3,4 の順位を r\ (=2) 位と確定させたのち、r に 2 を足して r=4 とする。
- 現時点で順位が未確定なのは人 1 であり、その中での得点の最大値は P_1\ (=3) である。よって、人 1 の順位を r\ (=4) 位と確定させたのち、r に 1 を足して r=5 とする。
- 4 人全員の順位が確定したため、手順を終了する。
入力例 2
3 3 9 6
出力例 2
3 1 2
入力例 3
4 100 100 100 100
出力例 3
1 1 1 1
入力例 4
8 87 87 87 88 41 38 41 38
出力例 4
2 2 2 1 5 7 5 7
Score : 200 points
Problem Statement
N people labeled from 1 to N participated in a certain contest. The score of person i (1 \leq i \leq N) was P_i.
In this contest, the rank of each of the N people is determined by the following procedure:
- Prepare a variable r, and initialize r = 1. Initially, the ranks of the N people are all undetermined.
- Repeat the following operation until the ranks of all N people are determined:
- Let x be the maximum score among the people whose ranks are currently undetermined, and let k be the number of people whose score is x. Determine the rank of those k people with score x to be r, and then add k to r.
Print the rank of each of the N people.
Constraints
- 1\leq N \leq 100
- 1\leq P_i \leq 100
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N P_1 P_2 \dots P_N
Output
Print N lines. The i-th line (1 \leq i \leq N) should contain the rank of person i as an integer.
Sample Input 1
4 3 12 9 9
Sample Output 1
4 1 2 2
The ranks of the N\ (=4) people are determined as follows:
- Prepare a variable r and initialize r=1. At first, the ranks of all 4 people are undetermined.
- Currently, persons 1, 2, 3, 4 have undetermined ranks. The maximum score among them is P_2\ (=12). Therefore, determine the rank of person 2 to be r\ (=1), and then add 1 to r, making r=2.
- Currently, persons 1, 3, 4 have undetermined ranks. The maximum score among them is P_3=P_4\ (=9). Therefore, determine the ranks of persons 3 and 4 to be r\ (=2), and then add 2 to r, making r=4.
- Currently, person 1 has an undetermined rank. The maximum score among them is P_1\ (=3). Therefore, determine the rank of person 1 to be r\ (=4), and then add 1 to r, making r=5.
- The ranks of all 4 people are now determined, so the process ends.
Sample Input 2
3 3 9 6
Sample Output 2
3 1 2
Sample Input 3
4 100 100 100 100
Sample Output 3
1 1 1 1
Sample Input 4
8 87 87 87 88 41 38 41 38
Sample Output 4
2 2 2 1 5 7 5 7