Guest User

Untitled

a guest
Oct 8th, 2017
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace p07_MaxSequenceOfIncreasingElements
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. long[] items = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
  15. long length = 1;
  16. long start = 0;
  17. long bestStart = 0;
  18. long bestLength = 1;
  19. long helper = 1;
  20.  
  21. for (int i = 0; i < items.Length; i++)
  22. {
  23. if (items[i] >= items[helper])
  24. {
  25. length++;
  26. helper++;
  27.  
  28. if (length > bestLength)
  29. {
  30. bestLength = length;
  31. bestStart = start;
  32. }
  33. }
  34. else
  35. {
  36. length = 1;
  37. start = i;
  38. helper = i;
  39. }
  40. }
  41. for (long j = bestStart; j < bestStart + bestLength; j++)
  42. {
  43. Console.Write(items[j]);
  44. Console.Write(" ");
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment