#C3582. Talent Show Ranking

    ID: 47025 Type: Default 1000ms 256MiB

Talent Show Ranking

Talent Show Ranking

In this problem, contestants in a talent show are ranked based on the average of their top three performance scores. Each performance record consists of a participant's name and his/her score. If a participant has fewer than three records, use all available scores to compute the average. The ranking is determined by sorting the participants in descending order of their average score. In the case of a tie, the participant with the lexicographically smaller name is considered first.

After computing the rankings, the output should list each participant and their rank, sorted alphabetically by their names.

The ranking is assigned as follows: the highest average score gets rank 1. If two or more participants share the same average, they receive the same rank. The next distinct average receives a rank counting all previous participants.

You are given the performance records via standard input and must output the final ranking list on standard output.

inputFormat

The first line contains a single integer n indicating the number of performance records.

Each of the following n lines contains a participant’s name and an integer score separated by a space.

You may assume that names do not contain spaces and scores are non-negative integers.

outputFormat

For each distinct participant, output a line with the participant's name and their rank, separated by a space. The output should be sorted in alphabetical order by the participant's name.

## sample
7
alice 500
bob 700
alice 600
alice 700
bob 800
alice 300
bob 750
alice 2

bob 1

</p>