#K3866. Longest Ascending Subsequence

    ID: 26248 Type: Default 1000ms 256MiB

Longest Ascending Subsequence

Longest Ascending Subsequence

You are given N mountains, each with a specified height. Your task is to determine the length of the longest strictly ascending subsequence of these mountains. In other words, find the maximum number of mountains you can select such that each selected mountain has a strictly greater height than the previous one.

Note: A subsequence is derived by deleting some or no elements without changing the order of the remaining elements.

The problem can be formulated using the following mathematical notation:

$$\text{Let } A = [a_1, a_2, \dots, a_N] \text{ be the list of heights. Find the maximum } k \text{ such that there exist indices } 1 \leq i_1 < i_2 < \dots < i_k \leq N \text{ with } a_{i_1} < a_{i_2} < \dots < a_{i_k}.$$

inputFormat

The first line of input contains a single integer N, which represents the number of mountains. The second line contains N space-separated integers representing the heights of the mountains.

If N is 0, then the second line will be empty.

outputFormat

Output a single integer: the length of the longest strictly ascending subsequence.

## sample
6
5 3 4 8 6 7
4