HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN_114 Midterm A > problem:


8. 51146 - Popular Baby Names

CEN_114 Midterm A

Start: May.14.2020 at 12:00:01 AM
Finish: May.31.2020 at 11:55:59 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 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

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2500/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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