#K3641. Longest Non-Decreasing Book Sequence

    ID: 25748 Type: Default 1000ms 256MiB

Longest Non-Decreasing Book Sequence

Longest Non-Decreasing Book Sequence

You are given a sequence of books, where each book has a certain number of pages. Your task is to find the length of the longest contiguous subsequence (sub-segment) where the number of pages is non-decreasing.

Formally, given an integer N and a list of integers P = [P1, P2, ..., PN], find the maximum length L such that for a contiguous subsequence Pi, Pi+1, ..., Pi+L-1 we have:

$$P_{j} \leq P_{j+1} \quad \text{for all } i \leq j < i+L-1. $$

If there are no books (i.e. N = 0), the answer is 0.

inputFormat

The input is given from stdin and consists of two lines:

  • The first line contains an integer N representing the number of books.
  • The second line contains N space-separated integers, where the i-th integer denotes the number of pages of the i-th book.

outputFormat

Output the length of the longest non-decreasing contiguous subsequence. The output should be written to stdout.

## sample
7
100 150 150 200 90 120 130
4