Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- var splitedInput = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
- //var input = "2 1 1 2 3 3 2 2 2 1";
- //var splitedInput = input.Split(" ").Select(int.Parse).ToArray();
- var cnt = 1;
- var maxCnt = 1;
- var num = string.Empty;
- for (int i = 0; i < splitedInput.Length - 1; i++)
- {
- if (splitedInput[i] == splitedInput[i + 1])
- {
- cnt++;
- if (cnt > maxCnt)
- {
- maxCnt = cnt;
- num = splitedInput[i].ToString();
- }
- }
- else
- {
- cnt = 1;
- }
- }
- for (int i = 0; i < maxCnt; i++)
- {
- Console.Write(num + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement