Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MaxSequence
- {
- static void Main()
- {
- int start = 0;
- int newStart = 0;
- int count = 1;
- int newCount = 1;
- int n = int.Parse(Console.ReadLine());
- int[] array = new int[n];
- for (int i = 0; i < n; i++)
- {
- array[i] = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] == array[i + 1])
- {
- count++;
- if (count > newCount)
- {
- newCount= count;
- newStart = start;
- }
- }
- else
- {
- count = 1;
- start = i + 1;
- }
- }
- for (int i = newStart; i < newStart + newCount; i++)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement