Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace P08LongestNonDecreasingSubsequence
- {
- class P08LongestNonDecreasingSubsequence
- {
- static void Main()
- {
- string input = Console.ReadLine();
- string[] list = input.Split(' ');
- int[] numbers = new int[list.Length];
- for (int i = 0; i < list.Length; i++)
- {
- numbers[i] = int.Parse(list[i]);
- }
- List<int> tempList = new List<int>();
- List<int> printList = new List<int>();
- for (int i = 0; i < numbers.Length; i++)
- {
- for (int j = i; j < numbers.Length; j++)
- {
- if (j == 0)
- {
- tempList.Add(numbers[j]);
- continue;
- }
- if (numbers[j] > tempList.Last())
- {
- tempList.Add(numbers[j]);
- }
- }
- if (tempList.Count > printList.Count)
- {
- printList = tempList;
- tempList.Clear();
- }
- }
- foreach (var item in printList)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement