## CCCHK '08 J3 - Phone book

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type

Nowadays, the systems in mobile phones are very user friendly. There is a shortcut button labelled Favourite for the most frequent dialed phone number so that you can make a phone call to that friend in a very short amount of time. The cellphone is smart enough to update the button dynamically.

Your job is to determine which phone number should be stored as the Favourite.

#### Input Specification

The input consists of two parts. The first part is the phone book showing the name of friends and their phone numbers. The second part is the phone numbers that have been dialed. The first integer in the input represents the total number of records in the phone book. Then each of the records follows on its own line. Each record starts with a name with no more than 20 characters (without any whitespace) and then a phone number with exactly 8 digits. Next, another integer in the input represents the total number of phone numbers that have been dialed. Finally, these phone numbers are listed, one per line.

#### Output Specification

For the most frequently dialed phone number, output the corresponding name. If there are two such numbers, output the one with the smaller phone number (where smaller mean numerically less than).

#### Sample Input

5
Mary 26000404
Susan 92132122
May 21232132
Ann 62343244
Peter 21321322
8
92132122
62343244
62343244
26000404
21321322
21232132
62343244
92132122

#### Sample Output

Ann

• commented on April 12, 2020, 1:09 a.m. edited

What is the HK supposed to mean in CCCHK?

• commented on April 12, 2020, 9:24 a.m.

Hong Kong

• commented on July 4, 2022, 5:53 p.m.

But doesn't CCC stand for Canadian Computing Contest? So it would be Canadian Computing Contest Hong Kong? Sorry, I'm not aware of any other meanings of CCC, I apologize if this question is stupid.

• commented on Dec. 28, 2018, 5:02 p.m.

will the first digit of the phone number ever be 0?

• commented on Jan. 21, 2019, 8:32 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.