Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Judge
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. //6 7 3 8 1 9 4 5 6 2 1 3
  13. int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. List<int> firstList = new List<int>();
  15. List<int> secondsList = new List<int>();
  16.  
  17. for(int i=0; i<array.Length-1;i++)
  18. {
  19. if(array[i]<array[i+1])
  20. {
  21. firstList.Add(array[i]);
  22. }
  23. else
  24. {
  25. firstList.Add(array[i]);
  26. if(firstList.Count>=secondsList.Count)
  27. {
  28. secondsList = firstList;
  29. }
  30. firstList = new List<int>();
  31. }
  32. }
  33. firstList.Add(array[array.Length - 1]);
  34. if(secondsList.Count==0)
  35. {
  36. Console.WriteLine(string.Join(" ",firstList));
  37. }
  38. else if(firstList.Count==secondsList.Count)
  39. {
  40. Console.WriteLine(string.Join(" ",firstList));
  41. }
  42. else
  43. {
  44. Console.WriteLine(string.Join(" ",secondsList));
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement