CCCHK '08 J3 - Phone book

View as PDF

Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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


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

    What is the HK supposed to mean in CCCHK?


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

      Hong Kong


  • 0
    rowan  commented on Nov. 2, 2019, 8:46 p.m.

    When I test it, my code seems to be working, but when I submit it I get IR for some of the questions. Does anybody know why?


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

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


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

      This comment is hidden due to too much negative feedback. Click here to view it.