HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > "Informatics Stars" Online Contests - 2011-2014 > problem:


2013-03-30. 50360 - National Elections

"Informatics Stars" Online Contests - 2011-2014

Start: Oct.20.2012 at 10:00:00 AM
Finish: Oct.20.2012 at 03:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 2012-11-30. 50656 - Divisibility by 11
• 2012-11-40. 50558 - Biggest Barn
• 2012-12-10. 50546 - Average Fuel P...
• 2012-12-20. 50574 - Triangular Nu...
• 2012-12-30. 50684 - Sum of prime ...
• 2013-01-10. 50584 - Total invoice ...
• 2013-01-30. 50599 - Sum of Squar...
• 2013-03-20. 50578 - Mersenne prime
• 2013-03-30. 50360 - National E...
• 2013-03-40. 50705 - Student Clubs
• 2014-04-10. 50547 - Close Pair
• 2014-04-30. 50560 - Max Distance
• 2014-04-50. 50569 - 12th Grade Ele...
• 2014-04-50. 50703 - The Shortest Path

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/7000/7000/7000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

National Elections

Babylonia Republic is going to have national elections this year. National Elections Organization Committee (NEOC) wants to use a computerized election system. During the elections they have stored all votes of all people with their IDs and the Candidate ID that he has voted for.

The following rules apply for the elections:

  • A voter may vote several times. Only his last vote is valid.
  • A vote is invalid, if it's zero (0) or if the voter didn't vote for anybody
NEOC wants the system to count the votes and to calculate the winner of the elections automatically. They also want to see the number of invalid votes. Write a program that is going to read the votes and calculate the winner.

Input specification
The first line contains two numbers: the number of voters (n) and the number of candidates (m) where 2 ≤ m ≤ 50 and 2 ≤ n ≤ 100000. Each of the following n lines contains two numbers: the id of the voter (j), and to whom he has voted for (k), where 1 ≤ j ≤ n and 0 ≤ k ≤ m.

Output specification
Show two numbers: candidate ID of the winner and the number of invalid votes.

Sample Input:
5 3
1 2
5 0
2 3
4 1
1 3

Sample Output:
3 2

Input Explanation:
There are 5 voter and 3 candidates:

  • Voter 1 has first voted for 2, then he has changed mind and decided to vote for Candidate 3
  • Voter 2 has voted for Candidate 3
  • Voter 3 hasn't voted for anybody, thus he has invalid vote.
  • Voter 4 has voted for Candidate 1
  • Voter 5 has voted for 0 (invalid vote)

Output Explanation: Candidate 3 has won the elections and there are 2 invalid votes.

Sample Input:
20 5
6 2
13 4
4 2
16 1
19 4
20 1
13 1
1 3
4 4
1 2
4 3
16 4
6 4
4 2
7 5
19 2
14 4
3 1
20 5
3 4

Sample Output:
4 10

Для отправки решений необходимо выполнить вход.

www.contester.ru