#B2158. Exam Rank Finder
Exam Rank Finder
Exam Rank Finder
In an exam, each student achieves a unique score. You are given each student's ID and score. Your task is to determine the student who achieved the $k$-th highest score, and output that student's ID along with their score.
Note: The ranking is based on the scores in descending order. That is, the student with the highest score is ranked 1, the second highest is ranked 2, and so on.
The relation can be mathematically represented as follows:
$$\text{Let } S = \{(id_i, score_i)\}_{i=1}^{n} \quad \text{and sort } S \text{ in descending order of } score_i, \quad \text{find } S[k-1]. $$inputFormat
The first line contains two integers n
and k
, where 1 ≤ k ≤ n. The following n
lines each contain a string (student ID) and an integer (score). The scores of all students are distinct.
outputFormat
Print the student ID and the score of the $k$-th ranked student. The output should contain the ID and score separated by a space.
sample
3 2
S001 90
S002 95
S003 85
S001 90