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

Турниры > CEN_114 Midterm A > задача:


8. 51146 - Popular Baby Names

CEN_114 Midterm A

Старт: 14.мая.2020 в 00:00:01
Финиш: 31.мая.2020 в 23:55:59
Турнир завершён!
• Турнирная таблица

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

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

• 13. 50735 - Top M Products
• 14. 51094 - Passing the course
• 15. 50804 - Marathon
• 3. 50390 - Total Salary Paid
• 4. 50528 - Rock-Scissors-Paper
• 5. 51087 - Are they the same?
• 6. 51092 - Even and Odd
• 7. 50449 - The biggest result
• 8. 51146 - Popular Baby Names
• 9. 50499 - Table to Row

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

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

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

Popular Baby Names

After birth, all babies are registered to the National Civil Registration Office (NCRO). The office publishes popular names periodically.

Question: Write a program that reads names of and gender of n babies from NCRO database. Then, your program must show the top popular m boy and girl names.

Input specification: You will be given two integers in the first line: (n) number of babies, (m) number of names to list. Starting from the second line, you will be given a char (F or M) and a name. The names contain only 26 English uppercase or lowercase letters and 1 ≤ m < n ≤ 50,0000.

Output specification: In the first line, show top popular m girl names Then, show top popular m boy names. Note: If there are baby names with the same number appearances, show them in ascending order according to the names.

Sample Input 1 Sample Input 2
10 2
M Leon
F Whitney
F Shelly
M Scott
M Casey
F Shelly
F Luz
M Scott
F Shelly
M Leon
12 2
M Clark
M Bill
F Latoya
M Clark
M Joshua
F Helen
M Clark
F Helen
M Scott
F Latoya
M Scott
M Jack
Sample Output 1 Sample Output 2
Shelly Luz
Leon Scott
Helen Latoya
Clark Scott

Explanation for sample input 1: There are 3 Shelly; 1 Luz; and 1 Whitney. Because Luz and Whitney appear the same number of times, they are shown in ascending order according to the names. So, Shelly and Luz.

There are 3 different boy names: 1 Casey; 2 Leon; 2 Scott. As a result: Leon and Scott are the most common boy names in this period.



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

www.contester.ru