Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace LongestIncreasingSubsequence
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[] sequence = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int[] len = new int[sequence.Length];
- int maxLength = 0;
- for (int currentI = 0; currentI < sequence.Length; currentI++)
- {
- len[currentI] = 1;
- for (int prevI = 0; prevI <= currentI - 1; prevI++)
- {
- if (sequence[currentI] > sequence[prevI] && len[prevI] >= len[currentI])
- {
- len[currentI] = len[prevI] + 1;
- }
- }
- if (len[currentI] > maxLength)
- {
- maxLength = len[currentI];
- }
- }
- Console.WriteLine(maxLength);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement