Advertisement
Hristo_B

Joro The Rabbit

Sep 9th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. using System;
  2.  
  3. class JoroTheRabbit
  4. {
  5.     static void Main()
  6.     {
  7.         string[] input = Console.ReadLine().Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
  8.         int[] valley = new int[input.Length];
  9.         for (int i = 0; i < input.Length; i++)
  10.         {
  11.             valley[i] = int.Parse(input[i]);
  12.         }
  13.  
  14.         int maxLength = 1;
  15.         for (int step = 1; step < valley.Length; step++)
  16.         {
  17.  
  18.             for (int startIndex = 0; startIndex < valley.Length; startIndex++)
  19.             {
  20.                 int currentLength = 1;
  21.                 int currentIndex = startIndex + step;
  22.                 int previousNumber = startIndex;
  23.  
  24.                 while (true)
  25.                 {
  26.                     if (currentIndex > valley.Length - 1)
  27.                     {
  28.                         currentIndex = currentIndex % valley.Length;
  29.                     }
  30.  
  31.                     if (currentIndex < 0)
  32.                     {
  33.                         break;
  34.                     }
  35.                     if (valley[currentIndex] > valley[previousNumber])
  36.                     {
  37.                         currentLength++;
  38.                         previousNumber = currentIndex;
  39.  
  40.                     }
  41.                     else
  42.                     {
  43.                         break;
  44.                     }
  45.  
  46.                     currentIndex += step;
  47.  
  48.                 }
  49.                 if (currentLength > maxLength)
  50.                 {
  51.                     maxLength = currentLength;
  52.                 }
  53.             }
  54.         }
  55.        
  56.         Console.WriteLine(maxLength);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement