#C14394. Student Ranking

    ID: 44038 Type: Default 1000ms 256MiB

Student Ranking

Student Ranking

You are given a list of students with their respective scores. The task is to sort the students in descending order of their scores using a stable sort (i.e. if two students have the same score, they should remain in their original input order). After sorting, you must find the rank of a specified student. The rank is defined as the 1-indexed position in the sorted list. If the student is not present in the list, output that the student is not ranked.

For example, if the sorted list is:

\( (\text{Charlie},92), (\text{Alice},88), (\text{Bob},67) \)

and you search for "Bob", the output should indicate that Bob is ranked 3, i.e., "Bob is ranked 3". Use LaTeX formatting for any embedded formulas.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n) representing the number of students. Each of the next (n) lines contains a student's name and score separated by a space. The final line contains the name to search for.

outputFormat

Output to standard output (stdout). First, print the sorted list of students in descending order by score; each student is printed on a new line in the format: name score. After printing the sorted list, print a single line indicating the ranking result. If the searched student is found, output: {name} is ranked {position}, otherwise, output: {name} is not ranked.## sample

3
Alice 88
Bob 67
Charlie 92
Bob
Charlie 92

Alice 88 Bob 67 Bob is ranked 3

</p>