Advertisement
petromaxa

Untitled

Dec 11th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _2.Problem_MissCat2011
  7. {
  8. class Program
  9. {
  10. static void Main()
  11. {
  12. int N = int.Parse(Console.ReadLine());
  13. int[] votes = new int[N];
  14. int voteCounter = 1;
  15. int currentWinner = 0;
  16. int winnerScore = 0;
  17. if (N > 0 && N < 100001)
  18. {
  19. for (int i = 0; i < N; i++)
  20. {
  21. votes[i] = int.Parse(Console.ReadLine());
  22. }
  23. Array.Sort(votes);
  24. currentWinner = votes[0];
  25. for (int i = 1; i < N; i++)
  26. {
  27. if (votes[i] == votes[i - 1])
  28. {
  29. voteCounter++;
  30. if (winnerScore < voteCounter)
  31. {
  32. currentWinner = votes[i];
  33. winnerScore = voteCounter;
  34. }
  35. }
  36. else
  37. {
  38. voteCounter = 1;
  39. }
  40. }
  41. Console.WriteLine(currentWinner);
  42. }
  43. else
  44. {
  45. Console.WriteLine("Wrong entry!");
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement