HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


51146 - Popular Baby Names

Guest
• Review clarifications (1)

Section problems

• 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
• 51132 - Problem Solving Competition
• 51121 - Complexity power of a nu...
• 51119 - Evaluating Prefix expressions
• 50563 - Long Modulus

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