#K75327. Longest Jump Sequence

    ID: 34395 Type: Default 1000ms 256MiB

Longest Jump Sequence

Longest Jump Sequence

Given an array of integers representing the heights of buildings, you are required to determine the length of the longest contiguous sequence of jumps. A jump is only allowed from one building to the next if the height of the next building is strictly greater than the current one.

Formally, if the array of heights is \(a_1, a_2, \dots, a_n\), define the length \(l_1 = 1\) and for \(i > 1\), \[ l_i = \begin{cases} l_{i-1}+1 &\text{if } a_i > a_{i-1},\\ 1 &\text{otherwise.} \end{cases} \] The task is to find \(\max_{1\le i\le n} l_i\).

For example, if the input is 2 1 2 3 1 (i.e. 5 buildings with heights [2, 1, 2, 3, 1]), the longest jump sequence has length 3.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains a single integer \(n\) (\(1 \le n \le 10^5\)), representing the number of buildings.
  • The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\) representing the heights of the buildings.

outputFormat

Output a single integer to standard output (stdout), representing the length of the longest contiguous jump sequence.

## sample
5
2 1 2 3 1
3