Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class JoroTheRabbit
- {
- static void Main()
- {
- string[] input = Console.ReadLine().Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
- int[] valley = new int[input.Length];
- for (int i = 0; i < input.Length; i++)
- {
- valley[i] = int.Parse(input[i]);
- }
- int maxLength = 1;
- for (int step = 1; step < valley.Length; step++)
- {
- for (int startIndex = 0; startIndex < valley.Length; startIndex++)
- {
- bool[] visited = new bool[valley.Length];
- visited[startIndex] = true;
- int currentLength = 1;
- int currentIndex = startIndex + step;
- int previousNumber = startIndex;
- while (true)
- {
- if (currentIndex > valley.Length - 1)
- {
- currentIndex = currentIndex % valley.Length;
- }
- if (currentIndex < 0)
- {
- break;
- }
- if (!visited[currentIndex] && valley[currentIndex] > valley[previousNumber])
- {
- visited[currentIndex] = true;
- currentLength++;
- previousNumber = currentIndex;
- }
- else
- {
- break;
- }
- currentIndex += step;
- }
- if (currentLength > maxLength)
- {
- maxLength = currentLength;
- }
- }
- }
- Console.WriteLine(maxLength);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement