#ABC134E. Sequence Decomposing

Sequence Decomposing

题目描述

You are given a sequence with NN integers: A={A1,A2,⋯ ,AN}A = \{ A_1, A_2, \cdots, A_N \}. For each of these NN integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:

  • If AiA_i and AjA_j (i<j)(i \lt j) are painted with the same color, Ai<AjA_i \lt A_j.

Find the minimum number of colors required to satisfy the condition.

给你一个包含 NN 个整数的序列: A={A1,A2,⋯ ,AN}A = \{ A_1, A_2, \cdots, A_N \} 。对于每一个 NN 整数,我们将选择一种颜色,并用这种颜色涂抹整数。这里必须满足以下条件:

  • 如果 AiA_i 和 AjA_j 被涂成 (i<j)(i \lt j) 。 (i<j)(i \lt j) 涂上相同的颜色,即 Ai<AjA_i \lt A_j 。

求满足条件所需的最少颜色数。

输入格式

输入内容按以下格式标准输入:

NN
A1A_1
::
ANA_N

输出格式

打印满足条件所需的最少颜色数。

样例 #1

样例输入 #1

5
2
1
4
5
3

样例输出 #1

2

样例 #2

样例输入 #2

4
0
0
0
0

样例输出 #2

4

说明

数据规模与约定

  • 1≤N≤1051 \leq N \leq 10^5
  • 0≤Ai≤1090 \leq A_i \leq 10^9

样例 11 解释

我们可以用两种颜色来满足条件,例如,将 22 和 33 涂成红色,将 11 、 44 和 55 涂成蓝色。

样例 22 解释

我们必须给所有整数涂上不同的颜色。