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 MaxSequenceOfEqualElements
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int count = 1;
- int max = 0;
- int start = 0;
- int bestLenght = 0;
- for (int i = 0; i < input.Length - 1; i++)
- {
- if (input[i]+1 == input[i + 1])
- {
- count++;
- if (count > max)
- {
- max = count;
- start = input[i];
- }
- }
- else
- {
- count = 1;
- }
- if (max == 1)
- {
- start = input[i];
- }
- bestLenght = start;
- }
- var result = input.Skip(start-2).Take(max);
- Console.WriteLine(string.Join(" ", result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement