#C8123. Ranking the Runners
Ranking the Runners
Ranking the Runners
You are given the number of runners and for each runner, their name and completion time. Your task is to rank the runners based on their finish times. If two or more runners have the same finishing time, they receive the same rank. The ranking is determined by sorting the times in ascending order, and the rank for a given time is assigned as the position of its first occurrence in the sorted order.
Formally, if the sorted times are \(t_1, t_2, \dots, t_n\), then the rank of a runner with time \(t\) is given by:
[ \text{rank}(t) = \min{ i \mid t_i = t } ]
Write a program that reads the input from stdin, processes the ranking, and writes the result to stdout with each line containing the runner's name and their rank separated by a space.
inputFormat
The input is read from standard input (stdin). The first line contains an integer \( n \) representing the number of runners. The following \( n \) lines each contain a runner's name (a string) and their completion time (an integer), separated by a space.
outputFormat
Output the list of runners sorted by their completion times. Each line of the output should contain the runner's name and their rank, separated by a space, written to standard output (stdout).
## sample1
Alice 120
Alice 1
</p>