All problems

Rank Every Day

mediumPythonSortingLists

Meridian's owner wants every day of the run labelled with where it stands: the best day is 1, the next best 2, on down to the worst. The labels have to sit beside the days in the order the days happened, not in rank order — the whole point is to see where in the week the good days fell. Two days often sell exactly the same, and the owner reads that the way a league table does: days that tie share the better of the labels they were arguing over, and the label directly under it goes unused.

Task: Print each day's rank.

Input

The first line holds an integer n, the number of days. Each of the next n lines holds one day's cup count, in day order. Counts may repeat.

Output

One line per day, n lines in all, in the order the days arrived: a whole number, 1 for the highest count, running down to n for the lowest when no two days tie. Days with equal counts all take the same rank — the best of the ones they would otherwise have shared — and the ranks immediately below it are skipped, so two days tied at the top are both 1 and the next day down is 3.

Example:

Input:
3
10
30
20

Output:
3
1
2

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…