#K12716. Assign Dish Ranks
Assign Dish Ranks
Assign Dish Ranks
You are given n dishes, each with a corresponding preference score. Your task is to assign ranks to the dishes so that the dish with the highest preference score receives rank 1, the second highest receives rank 2, and so on. In case of equal preference scores, the dish that appears earlier in the input retains the higher rank.
The goal is to order the dishes in descending order of preference, and then output the rank for each dish in its original order.
inputFormat
The input is provided via standard input (stdin) in two lines. The first line contains a single integer n — the number of dishes. The second line contains n space-separated integers, where the ith integer represents the preference score of the ith dish.
outputFormat
Output a single line to standard output (stdout) containing n space-separated integers. The ith integer denotes the rank assigned to the ith dish according to the described ranking procedure.
## sample4
3 6 2 5
3 1 4 2
</p>