ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Linear Data Structures: Arrays > задача:


51123 - Mr. Li Criteria

Гость
• Вопросы к жюри (1)

Задачи раздела

• Question 1
• 51135 - Class Average 1
• 51136 - Class Average 2
• 51094 - Passing the course
• 51130 - Permutation of Everything
• 51069 - Last Digit of a Fibonacci Nu...
• 51073 - Campus Tours for High Sch...
• 51148 - Circles
• 51123 - Mr. Li Criteria
• 51124 - Easy Tiae words
• 51145 - Graduation Exam
• 51117 - The Most Crowded
• 51146 - Popular Baby Names
• 51131 - Running After a Thief
• 51143 - Departments Competition
• 50994 - The Most Crowded Station
• 51118 - Place 7 to the 5th position

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 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.



Для отправки решений необходимо выполнить вход.

www.contester.ru