SHARE
TWEET

Untitled

a guest May 23rd, 2016 218 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
  9.         int maxCount = 0;
  10.         int maxStart = 0;
  11.         int currentCount = 1;
  12.         int currentStart = 0;
  13.         for (int i = 1; i < array.Length; i++)
  14.         {
  15.             if (array[i]==array[i-1])
  16.             {
  17.                 currentCount++;
  18.                 if (currentCount > maxCount) { maxCount = currentCount; maxStart = currentStart; }
  19.             }
  20.             else
  21.             {
  22.                 currentCount = 1;
  23.                 currentStart = i;
  24.             }
  25.         }
  26.         int[] result = array.Skip(maxStart).Take(maxCount).ToArray();
  27.         Console.WriteLine(string.Join(" ", result));
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top