CCCHK '08 J3 - Phone book

View as PDF

Submit solution

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 N in the input (\le 10\,000) represents the total number of records in the phone book. Then each of the N 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 D (\le 10\,000) in the input represents the total number of phone numbers that have been dialed. Finally, these D 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

Comments


  • 3
    Togohogo1  commented on April 12, 2020, 5:09 a.m. edited

    What is the HK supposed to mean in CCCHK?


    • 10
      MehMehMeh  commented on April 12, 2020, 1:24 p.m.

      Hong Kong


      • 7
        rnpmat08  commented on July 4, 2022, 9: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.


  • 4
    XTTH  commented on Dec. 28, 2018, 10:02 p.m.

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


    • -17
      Arihan10  commented on Jan. 22, 2019, 1:32 a.m.

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