ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Неотсортированные > задача:


Towers

Задачи раздела

• Minimizing Coins
• Missing Coin Sum
• Playlist
• Concert Tickets
• Collecting Numbers
• Coin Combinations I
• Josephus Queries
• Money Sums
• Towers
• Apartments
• Traffic Lights
• Stick Lengths
• Static Range Sum Queries
• Exponentiation
• A+B
• A. Бактерии
• A. Любимые числа

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Сложность Альфа

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 k1,k2,…,kn : the sizes of the cubes.

Output
Print one integer: the minimum number of towers.

Constraints
  • 1≤n≤2⋅105
  • 1≤k(i)≤109

Example
Input:
5
3 8 2 1 5

Output:
2

Для отправки решений необходимо выполнить вход.

www.contester.ru