Advertisement
Kuncavia

LongestIncreasingSequence

Oct 2nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int[] arr = new int[n];
  9.         int cnt = 1;
  10.         int max = 1;
  11.         for (int i = 0; i < n; i++)
  12.         {
  13.             arr[i] = int.Parse(Console.ReadLine());
  14.         }
  15.         for (int i = 0; i < n - 1; i++)
  16.         {
  17.             if (arr[i + 1] - arr[i] >= 1)
  18.             {
  19.                 cnt++;
  20.                 if (cnt > max)
  21.                 {
  22.                     max = cnt;
  23.                 }
  24.             }
  25.             else
  26.             {
  27.                 cnt = 1;
  28.             }
  29.         }
  30.         Console.WriteLine(max);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement