BonchoBelutov

MaximalIncreasingSequence

May 3rd, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace MaximalIncreasingSequence
  8. {
  9.     class MaximalIncreasingSequence
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             var arr = new int[n];
  15.             int countOccur = 1;
  16.             int bestCount = 0;
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 arr[i] = int.Parse(Console.ReadLine());
  20.             }
  21.             for (int i = 0; i < arr.Length - 1; i++)
  22.             {
  23.                 if (arr[i] < arr[i + 1])
  24.                 {
  25.                     countOccur++;
  26.                 }
  27.                 else
  28.                 {
  29.                     if (countOccur > bestCount)
  30.                     {
  31.                         bestCount = countOccur;
  32.                     }
  33.                     countOccur = 1;
  34.                 }
  35.             }
  36.             if (countOccur > bestCount)
  37.             {
  38.                 bestCount = countOccur;
  39.             }
  40.             Console.WriteLine(bestCount);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment