#K96337. Longest Increasing Sequence in a Matrix Row

    ID: 39064 Type: Default 1000ms 256MiB

Longest Increasing Sequence in a Matrix Row

Longest Increasing Sequence in a Matrix Row

In this problem, you are given a matrix with (n) rows and (m) columns, where each cell has an integer height. A palace is defined as a sequence of consecutive cells in a single row such that each cell is strictly higher than the previous one. Formally, for a given row (A_{i,1}, A_{i,2}, \dots, A_{i,m}), you need to find a contiguous subsequence where (A_{i,j+1} > A_{i,j}) for all valid (j). Your task is to determine the maximum length of such a sequence among all rows.

For instance, if one row is (1\ 2\ 3\ 4\ 5) then the maximum sequence length is 5. If another row is (4\ 3\ 2\ 1) then the sequence length is 1 since no two consecutive cells satisfy the condition.

inputFormat

The first line contains two integers (n) and (m), where (n) is the number of rows and (m) is the number of columns. Each of the following (n) lines contains (m) space-separated integers representing the elements of the matrix.

outputFormat

Output a single integer representing the maximum number of consecutive cells in any row that form a strictly increasing sequence.## sample

4 5
1 2 3 4 5
4 3 2 1 0
5 6 7 8 9
1 3 2 4 6
5

</p>