6743.Increasing Subsequence

Time Limit: 1s Memory Limit: 512MB

You are given an array containing $n$ integers. Your task is to determine the longest increasing subsequence in the array, i.e., the longest subsequence where every element is larger than the previous one.

A subsequence is a sequence that can be derived from the array by deleting some elements without changing the order of the remaining elements.

Input Format(From the terminal/stdin)

The first line contains an integer $n$ : the size of the array.

After this there are $n$ integers $x_1,x_2,\ldots,x_n$ : the contents of the array.

  • $1 \le n \le 2 \cdot 10^5$
  • $1 \le x_i \le 10^9$

Output Format(To the terminal/stdout)

Print the length of the longest increasing subsequence.

Sample Input

Copy
8
7 3 5 3 6 2 9 8
 \n
 · · · · · · · \n

Sample Output

Copy
4
 \n
Source: CSES, Dynamic Programming, 1145

Submit

请先 登录

© 2025 FAQs