CSES - Towers

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/1073
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

You are given ~n~ cubes in a certain order, and your task is to build towers using them. Whenever two cubes are one on top of the other, the upper cube must be smaller than the lower cube.

You must process the cubes in the given order. You can always either place the cube on top of an existing tower, or begin a new tower. What is the minimum possible number of towers?

Input

  • The first input line contains an integer ~n~: the number of cubes.

The next line contains ~n~ integers ~k\_1,k\_2,\ldots,k\_n~: the sizes of the cubes.

Output

  • Print one integer: the minimum number of towers.

Constraints

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

Example Input

5
3 8 2 1 5

Example Output

2

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.