Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _2.Problem_MissCat2011
- {
- class Program
- {
- static void Main()
- {
- int N = int.Parse(Console.ReadLine());
- int[] votes = new int[N];
- int voteCounter = 1;
- int currentWinner = 0;
- int winnerScore = 0;
- if (N > 0 && N < 100001)
- {
- for (int i = 0; i < N; i++)
- {
- votes[i] = int.Parse(Console.ReadLine());
- }
- Array.Sort(votes);
- currentWinner = votes[0];
- for (int i = 1; i < N; i++)
- {
- if (votes[i] == votes[i - 1])
- {
- voteCounter++;
- if (winnerScore < voteCounter)
- {
- currentWinner = votes[i];
- winnerScore = voteCounter;
- }
- }
- else
- {
- voteCounter = 1;
- }
- }
- Console.WriteLine(currentWinner);
- }
- else
- {
- Console.WriteLine("Wrong entry!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement