Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Mr. Li Criteria
The names in China is usually quite short. And director Li wants
the lists according to the length of names: the shortest name
at the top. If there are several names with the same
length, then to be sorted in ascending order according to
the grades. If the grades are the same too, then
show students in the alphabetical order (A comes before B).
Question: Write a program
that reads a list of (n) students with their grades.
Then, the program prints the top (m) students according
to given Director Li criteria.
Input specification:
First, you will be given two integers: number of
students (n), and number of top students to show
(m). The following n lines contain the name and grade
of n students where 0 ≤ m ≤ n ≤ 50,000.
Output specification:
Show m student names with their grades in m lines.
Sample Input 1 |
Sample Input 2 |
7 3
Deng 35
Xun 66
Li 57
Wan 66
Tan 66
Gao 67
Jiang 54
|
8 4
Fang 75
Cui 58
Qiao 46
Deng 36
Lang 47
Han 96
Long 57
Gu 74
|
Sample Output 1 |
Sample Output 2 |
Li 57
Tan 66
Wan 66
|
Gu 74
Cui 58
Han 96
Deng 36
|
Explanation: The list
of students sorted according to Mr.
Li criteria for the sample input 1:
Li 57
Tan 66
Wan 66
Xun 66
Gao 67
Deng 35
Jiang 54
Students Tan Wan and Xun have the same name length
and same grades, thus, they are put in ascending
order according to the names. Gao has the same
name length but his grade is above the others and
so (s)he comes after Tan, Wan and Xun.
Для отправки решений необходимо выполнить вход.
|