#C11547. Rank Runners
Rank Runners
Rank Runners
You are given a list of runners with their respective finish times in a race. Your task is to rank the runners by their finish times in increasing order.
The input consists of the number of runners followed by the runners' data (a name and a time). Your program should output the ranking: each line contains the rank (starting from 1), the runner's name, and the time. In case of ties, maintain the original input order.
Formally, if we denote the finish times by \(t_i\) for \(i=1,2,\ldots,n\), you should produce ranks such that if \(t_a < t_b\) then the rank of runner \(a\) is lower than the rank of runner \(b\). When \(t_a = t_b\), the runner that appears earlier in the input should have a higher ranking.
inputFormat
The first line contains an integer \(n\) representing the number of runners. The next \(n\) lines each contain a string and a floating point number separated by a space, where the string is the runner's name and the number is the finish time.
Example:
3 Alice 320.5 Bob 300.1 Charlie 305.7
outputFormat
Output \(n\) lines. Each line should contain the ranking (an integer starting from 1), the runner's name, and their finish time, separated by a space. The runners should be ordered by ascending finish time.
Example output for the sample input:
1 Bob 300.1 2 Charlie 305.7 3 Alice 320.5## sample
3
Alice 320.5
Bob 300.1
Charlie 305.7
1 Bob 300.1
2 Charlie 305.7
3 Alice 320.5
</p>