Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- //17:22 - 18:06 - 80%
- //18:11 90%
- static void Main()
- {
- var nums = Console.ReadLine()
- .Split(new[] { ", " },
- StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToList();
- long seqLength = nums.Count;
- long maxLength = 0;
- //var visitedNodes = new HashSet<long>(); - you do not need it!
- for (int step = 1; step < seqLength; step++)
- {
- for (int stNode = 0; stNode < seqLength; stNode++)
- {
- var localMax = 1;
- var currentElementIndex = stNode;
- var nextElementIndex = (currentElementIndex + step) % nums.Count;
- while (nums[nextElementIndex] > nums[currentElementIndex])
- {
- localMax++;
- currentElementIndex = nextElementIndex;
- nextElementIndex = (currentElementIndex + step) % nums.Count;
- }
- if (maxLength < localMax)
- {
- maxLength = localMax;
- }
- }
- }
- Console.WriteLine(maxLength);
- //Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement