#C4526. Longest Continuous Increasing Subsequence

    ID: 48074 Type: Default 1000ms 256MiB

Longest Continuous Increasing Subsequence

Longest Continuous Increasing Subsequence

Given an array of integers, your task is to determine the length of the longest continuous increasing subsequence. A continuous increasing subsequence is a subarray where each element is strictly greater than its preceding element.

For example, given the array [1, 3, 5, 4, 7, 8], the longest continuous increasing subsequence is [1, 3, 5] which has a length of 3.

The algorithm follows a simple linear scan: maintain a current increasing length counter and update the maximum length when a strictly increasing trend continues. In the case of a break in the sequence, reset the counter.

Mathematically, if we denote the array by \(a_1, a_2, \ldots, a_n\), then we look for the maximum \(L\) satisfying:

\[ L = \max_{1 \leq i \leq n} \{\ell : a_{i+\ell-1} > a_{i+\ell-2} \text{ for } \ell \ge 2\} \]

inputFormat

The input is given via standard input (stdin) as follows:

  • The first line contains an integer \(n\) representing the number of elements in the array. (\(0 \leq n \leq 10^5\))
  • If \(n > 0\), the second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

Output the length of the longest continuous increasing subsequence to standard output (stdout) as a single integer.

## sample
6
1 3 5 4 7 8
3

</p>