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;
- using System.Threading.Tasks;
- namespace SoftUni
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> nums = new List<int>();
- nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- int pos = 0;
- int count = 1;
- int bestPos = 0;
- int bestCount = 1;
- do
- {
- if (nums.Count == 1)
- {
- break;
- }
- if (nums[pos] != nums[pos + 1])
- {
- count = 1;
- pos++;
- }
- else if (nums[pos] == nums[pos + 1])
- {
- count++;
- pos++;
- }
- if (bestCount < count)
- {
- bestCount = count;
- bestPos = pos + 1 - bestCount;
- }
- }
- while (pos + 1 < nums.Count);
- for (int i = bestPos; i < (bestPos + bestCount); i++)
- {
- Console.Write(nums[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement