CSES - Increasing Subsequence

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/1145
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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

  • 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.

Output

  • Print the length of the longest increasing subsequence.

Constraints

  • ~1 \le n \le 2 \cdot 10^5~
  • ~1 \le x\_i \le 10^9~

Example Input

8
7 3 5 3 6 2 9 8

Example Output

4

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.