408000: GYM102961 N Towers
Memory Limit:256 MB
Time Limit:0 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
N. Towerstime limit per test2.0 smemory limit per test256 megabytesinputstandard inputoutputstandard output
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?
InputThe first input line contains an integer $$$n$$$: the number of cubes.
The next line has $$$n$$$ integers $$$k_1,k_2,\dots,k_n$$$: the size of the cubes.
Constraints:
- $$$1 \le n \le 2\cdot 10^5$$$
- $$$1 \le k_i \le 10^9$$$
Print one integer: the minimum number of towers.
ExampleInput5 3 8 2 1 5Output
2