P9726 [EC Final 2022] Magic
题目描述
**Warning: Unusual memory limit!**
You are given a sequence $a_0,\ldots,a_{2n}$. Initially, all numbers are zero.
There are $n$ operations. The $i$-th operation is represented by two integers $l_i, r_i$ ($1\le l_i < r_i\le 2n, 1\le i\le n$), which assigns $i$ to $a_{l_i},\ldots,a_{r_i-1}$. It is guaranteed that all the $2n$ integers, $l_1,l_2,\ldots, l_n, r_1, r_2, \ldots, r_n$, are distinct.
You need to perform each operation exactly once, in arbitrary order.
You want to maximize the number of $i$ $(0\leq i< 2n)$ such that $a_i\neq a_{i+1}$ after all $n$ operations. Output the maximum number.
输入格式
无
输出格式
无