#C1859. Longest Non-Decreasing Subsequence

    ID: 45110 Type: Default 1000ms 256MiB

Longest Non-Decreasing Subsequence

Longest Non-Decreasing Subsequence

Given a list of integers, your task is to determine the length of the longest non-decreasing subsequence. A subsequence is a sequence that can be derived from the list by deleting zero or more elements without changing the order of the remaining elements. In a non-decreasing subsequence, each element is greater than or equal to the one before it.

For example, if the input list is [10, 9, 2, 5, 3, 7, 101, 18], one of the longest non-decreasing subsequences is [2, 5, 7, 101] which has a length of 4.

Solve the problem by reading the input from standard input and writing the output to standard output.

inputFormat

The input consists of two lines. The first line contains a single integer N representing the number of elements in the list. The second line contains N space-separated integers representing the list elements. If N is 0, it indicates that the list is empty.

outputFormat

Output a single integer which is the length of the longest non-decreasing subsequence in the given list.

## sample
8
10 9 2 5 3 7 101 18
4

</p>