CSES Problemset/Sorting and Searching
Towers
#1073Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopYou are given 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 : the number of cubes.
The next line contains integers : the sizes of the cubes.
Output
Print one integer: the minimum number of towers.
Constraints
Sample Test Cases (1)
Example 1ID: sample-1
Input
5 3 8 2 1 5
Expected Output
2
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
5 3 8 2 1 5
Expected Output
2