Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
Most Visited
You start working on a company and you are administering
the website. The boss is frequently asking information
for the site. He is following daily visits, most visited
pages etc. He wants you to prepare something that helps
him. Every page has an ID, name and some content. Whenever
a pages is clicked, page ID is sent to the server. And in
the server there are some scripts that increments the
counter for that page.
Question:
You will be given the name and id of n web pages. Then
you will be given a series of page IDs. You need to
figure out the most visited page. Note: Pay attention
that there are also hackers trying to break your
system and there are several fake page IDs.
Input specification
You will be first given two integers: the number of web
pages (n) and the number of pageviews (m) where
1 ≤ n ≤ 10,000 and 1 ≤ m ≤ 20,000. Then in
the following n lines you will be given the
information for n web pages. Every line contains:
- webpage ID: a unique integer which is
between 1 and 200,000.
- Webpage name: a string which contains any ASCII
char and there are at most 100 chars
After that, you will be given m numbers in several
lines (25 numbers per line). Each number is between
0 and 2e9
Output specification
Show two information:
- The number number of fake pageviews
- The name of the most visited page
If there are several pages with the same number of
most visits, show the one with the smaller ID.
Sample Input I
5 12
2 Main Site
5 Login page
3 Administration login page
7 Contacts & maps
6 Forum and Discussions
6 4 5 5 6 5 1 3 6 3 7 1
|
Sample Output I
3
Login Page
|
Explanation:
There are 5 webpages and 12 pageviews. There are 3 fake
pageviews: two 1s and a 4. Pages with the ID 5 and 6 have
3 pageviews. So, Login page is the first top visited webpage.
Для отправки решений необходимо выполнить вход.
|