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

Турниры > CEN112 Questions 2016 > задача:


15-PE-8. 50872 - Top M Grades

CEN112 Questions 2016

Старт: 30.мар.2016 в 15:10:22
Финиш: 01.апр.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

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

Задачи турнира

• 15-MdtE-4. 50917 - Descending Nu...
• 15-MdtE-5. 50912 - Trip to Librazhd
• 15-MdtE-6. 50914 - Buy 3, Pay 2
• 15-PE-1. 50865 - Apartment Building...
• 15-PE-2. 50866 - Buy the cheapest
• 15-PE-4. 50868 - Sort Frequencies
• 15-PE-5. 50869 - Birthday Celebration
• 15-PE-7. 50871 - Harmonic Mean
• 15-PE-8. 50872 - Top M Grades
• 15-PE2-1. 50980 - The smallest rect...
• 15-PE2-2. 50981 - Top popular m-st...
• 15-PE2-2. 50984 - Top m hardworki...
• 15-PE2-2. 51086 - Top popular student
• 15-PE2-3. 50982 - A thief in labyrinth
• 15-PE2-4. 50983 - Course Selection
• 15-PE2-6. 50985 - Books Waiting
• 15-PE2-8. 50987 - Very Looong Queue

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

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

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan and Sidrit Reka.

Top M Grades

Question: A math professor who is very interested into statistics wants to calculate the best grades of his students. So, he will take the best grade of each student and from these grades, he will print only the top m grades.

Question: Given the number of students and the grades of each student, find the top m grades from all the student's best grades and print them in descending order.

Input specification
In the first line you will be given two numbers n and m (3 <= n <= 10.000 && 1 <= m <= 100) where n determines the number of students and m determines the number of top grades to print. In the following n lines, you will be given a list of integer grades (1 <= grade <= 100) which ends with -1. Each line determines the grades of each student.

Output specification:
Write the top m grades from all the student's best grades in descending order.

Sample Input I
3 2
5 31 57 77 19 -1
27 96 11 60 47 58 -1
90 72 42 -1
Sample Input II
5 3
9 27 33 81 78 93 3 -1
8 79 32 20 77 -1
68 72 38 -1
79 1 20 5 55 92 -1
92 15 22 12 -1
Sample Output I
96 90
Sample Output II
93 92 92

Explanation Sample Input I: The best grade of the first student is 77. The best grade of the second student is 96. The best grade of the third student is 90. The top 2 grades in descending order are 96 and 90.

Explanation Sample Input II: The best grade of the first student is 93. The best grade of the second student is 79. The best grade of the third student is 72. The best grade of the fourth student is 92. The best grade of the fifth student is 92. The top 3 grades in descending order are 93, 92 and 92.



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

www.contester.ru