Longest Ascending Contiguous Subsequence
InterviewTime limit2sMemory limit512 MB
Given a sequence of positive integers, find the length of the longest contiguous run whose elements are non-decreasing.
- Level
Easy2 of 10
- Topics
- Array, Implementation, Brute force
- Solved
- No attempts yet
Problem
Given a sequence of positive integers A=(A1, A2, ..., AN) of length N. Find the length of the longest contiguous subsequence of A that is sorted in ascending order.
In other words, find the maximum value of r-l+1 over all pairs of integers l, r (1 ≦ l ≦ r ≦ N) satisfying Al ≦ Al+1 ≦ ... ≦ Ar.
Input
The input is given from standard input in the following format.
N
A1 A2 ... AN
Output
Print the length of the longest contiguous subsequence of the positive integer sequence A that is sorted in ascending order, on a single line.
Constraints
1 ≦ N ≦ 100.1 ≦ Ai ≦ 2020(1 ≦ i ≦ N).