SHARE
TWEET

CryptoMaster

a guest Jan 20th, 2018 269 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.         //17:22 - 18:06 - 80%
  7.         //18:11 90%
  8.  
  9.         static void Main()
  10.         {
  11.             var nums = Console.ReadLine()
  12.                 .Split(new[] { ", " },
  13.                     StringSplitOptions.RemoveEmptyEntries)
  14.                 .Select(long.Parse)
  15.                 .ToList();
  16.  
  17.             long seqLength = nums.Count;
  18.             long maxLength = 0;
  19.             //var visitedNodes = new HashSet<long>(); - you do not need it!
  20.  
  21.             for (int step = 1; step < seqLength; step++)
  22.             {
  23.                 for (int stNode = 0; stNode < seqLength; stNode++)
  24.                 {
  25.                     var localMax = 1;
  26.  
  27.                     var currentElementIndex = stNode;
  28.                     var nextElementIndex = (currentElementIndex + step) % nums.Count;
  29.  
  30.                     while (nums[nextElementIndex] > nums[currentElementIndex])
  31.                     {
  32.                         localMax++;
  33.                        
  34.                         currentElementIndex = nextElementIndex;
  35.                         nextElementIndex = (currentElementIndex + step) % nums.Count;
  36.                     }
  37.  
  38.                     if (maxLength < localMax)
  39.                     {
  40.                         maxLength = localMax;
  41.                     }
  42.                 }
  43.             }
  44.  
  45.             Console.WriteLine(maxLength);
  46.             //Console.ReadLine();
  47.         }
  48.     }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top