Advertisement
stoianpp

JorroTheRabbit

Jan 5th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         char[] separators = { ' ', ',' };
  9.         string[] input = Console.ReadLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);
  10.         int[] terrain = new int[input.Length];
  11.         for (int i = 0; i < input.Length; i++) terrain[i] = int.Parse(input[i]);
  12.         JumpingArround(terrain);
  13.     }
  14.  
  15.     static void JumpingArround(int[] terrain)
  16.     {
  17.         int steps = 0;
  18.         for (int i = 0; i < terrain.Length; i++)
  19.         {
  20.             for (int g = 1; g < terrain.Length; g++)
  21.             {
  22.                 int indexPosition = i;
  23.                 int currSteps = 1;
  24.                 while (terrain[indexPosition] < terrain[(indexPosition + g) % terrain.Length])
  25.                 {
  26.                     currSteps++;
  27.                     indexPosition += g;
  28.                     if (indexPosition >= terrain.Length) indexPosition %= terrain.Length;
  29.                 }
  30.                 if (currSteps > steps) steps = currSteps;
  31.             }
  32.         }
  33.         Console.WriteLine(steps);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement