CF1479B1 Painting the Array I
题目描述
### 题意
**本题与 CF1480D2 的唯一区别是本题询问最大可能解.**
给定一个数组 $a$, 你将将 $a_i$ 染为 $b_i$ 色, 其中 $b$ 是由你指定的一个 **01 数组**. 将 $a$ 数组中被染成 0 色的数字取出来并依在 $a$ 中出现的顺序排列, 组成数组 $a^{(0)}$. 同理, 将 $a$ 数组中被染成 1 色的数字取出来并依在 $a$ 中出现的顺序排列, 组成数组 $a^{(1)}$. 我们定义 $seg(c)$ 是一个正整数, 其中 $c$ 是一个数组, $seg(c)$ 的值为在我们将 $c$ 中相邻的所有相同元素合并后, $c$ 数组的大小. 例如, $seg([1, 1, 4, 5, 1, 4]) = |[1, 4, 5, 1, 4]|=5$. 最大化 $seg(a^{(0)})+seg(a^{(1)})$.
输入格式
第一行包括一个正整数 $n(1\leq n\leq 10^5)$.
第二行包括 $n$ 个正整数 $a_1, a_2, \cdots,a_n(1\leq a_i\leq n)$.
输出格式
仅输出一个正整数, 代表最大的 $seg(a^{(0)})+seg(a^{(1)})$.
说明/提示
In the first example, we can choose $ a^{(0)} = [1,2,3,3] $ , $ a^{(1)} = [1,2,3] $ and $ \mathit{seg}(a^{(0)}) = \mathit{seg}(a^{(1)}) = 3 $ . So the answer is $ 3+3 = 6 $ .
In the second example, we can choose $ a^{(0)} = [1,2,3,4,5,6,7] $ and $ a^{(1)} $ is empty. We can see that $ \mathit{seg}(a^{(0)}) = 7 $ and $ \mathit{seg}(a^{(1)}) = 0 $ . So the answer is $ 7+0 = 7 $ .