-->
当前位置:首页 > 题库

PROGRAMMING:Ranking

Luz5年前 (2021-05-10)题库413
As we all know, Keven's training team often holds competitions, but the ranking statistics of each competition is a big trouble, so Keven finds you and gives you the score of this competition. I hope you can help him count the ranking of the top k players in this competition.
###Input format:
Input two integers in the first line, which are n (not more than 10000 positive integers, the total number of students) and K (not more than 100 positive integers, not more than n). Next N lines, each line gives a student's account number (a string of no more than 15 digits in length and without spaces) and competition results (integers in the interval [0, 100]), separated by spaces. The title guarantees that there are no duplicate accounts.
###Output format:
Then output the ranking, account number and score of the top k students in non ascending order according to the total score, separated by a space. It should be noted that: students with the same score enjoy a parallel ranking. When the ranking is parallel, it is output in ascending order according to the alphabetic order of the account number.
It should be noted that:
Students with the same score enjoy a parallel ranking. When the ranking is parallel, it will be output in ascending order according to the alphabetic order of the account number. See the second example for details.
Suppose there are three students whose grades are 100, 100 and 80 respectively, then the ranking of the two students with 100 points should be 1, and the ranking of the students with 80 points should be 3.
###Input sample 1:
```in
10 5
cy@zju.edu.cn seventy-eight
cy@pat-edu.com eighty-seven
1001@qq.com sixty-five
uh-oh@163.com ninety-six
test@126.com thirty-nine
anyone@qq.com eighty-seven
zoe@mit.edu eighty
jack@ucla.edu eighty-eight
bob@cmu.edu eighty
ken@163.com seventy
```
###Output sample 1:
```out
one uh-oh@163.com ninety-six
two jack@ucla.edu eighty-eight
three anyone@qq.com eighty-seven
three cy@pat-edu.com eighty-seven
five bob@cmu.edu eighty
five zoe@mit.edu eighty
```
###Input sample 2:
```in
5 1
cy@zju.edu.cn one hundred
cy@pat-edu.com one hundred
1001@qq.com one hundred
uh-oh@163.com ninety-six
test@126.com thirty-nine
```
###Output sample 2:
```out
one 1001@qq.com one hundred
one cy@pat-edu.com one hundred
one cy@zju.edu.cn one hundred
```







answer:If there is no answer, please comment