ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > "Informatics Stars" Online Contests - 2011-2014 > задача:


2013-03-30. 50360 - National Elections

"Informatics Stars" Online Contests - 2011-2014

Старт: 20.окт.2012 в 10:00:00
Финиш: 20.окт.2012 в 15:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• 2012-11-30. 50656 - Plotpjestuesh...
• 2012-11-40. 50558 - Hangari i madh...
• 2012-12-10. Cmimi Mesatar i Karbu...
• 2012-12-20. 50574 - Numrat Treke...
• 2012-12-30. 50684 - Shuma e numr...
• 2013-01-10. 50584 - Pagesa totale
• 2013-01-30. 50599 - Shuma e katro...
• 2013-03-20. 50578 - Numrat Prim M...
• 2013-03-30. 50360 - National E...
• 2013-03-40. 50705 - Klubet e studen...
• 2014-04-10. Cifti me i afert
• 2014-04-30. 50560 - Distanca maks...
• 2014-04-50. 50569 - Lendet me zgj...
• 2014-04-50. 50703 - Rruga me e sh...

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 4000/7000/7000/7000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
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