#C2771. Determine Student Ranks

    ID: 46124 Type: Default 1000ms 256MiB

Determine Student Ranks

Determine Student Ranks

You are given n students, each with a specific height. Your task is to assign each student a rank based on their height, in ascending order. The student with the smallest height receives rank 1, and so on. In the event of students having equal heights, the order of appearance in the input is preserved. Formally, if two students have the same height, the one who appeared earlier in the input should receive the lower rank.

Note: It is guaranteed that all ranks will be unique integers between 1 and n.

Input and Output Requirements:
Read input from stdin and output the result to stdout.

The ranking essentially sorts the heights in non-decreasing order while keeping the original order for ties. In mathematical notation, if the sorted order of heights is given by \(a_{i_1} \le a_{i_2} \le \cdots \le a_{i_n}\), then the rank assigned to the student at position \(i_j\) is \(j\).

inputFormat

The input consists of two lines:

  1. The first line contains an integer n which represents the number of students.
  2. The second line contains n space-separated integers representing the heights of the students.

All input is read from stdin.

outputFormat

Output n space-separated integers in one line, where the i-th number represents the rank of the i-th student from the input. The result should be printed to stdout.

## sample
5
170 150 160 160 180
4 1 2 3 5