AtCoder Regular Contest 159
翻译中…
Problem Statement
翻译中…
We have a sequence $X$, which is initially empty.
Takahashi has performed the following operation for $i=1,2,\ldots,N$ in this order.
翻译中…
- Append
$l_i,l_i+1,\ldots,r_i$in this order to the end of$X$.
翻译中…
Find the greatest length of a strictly increasing subsequence of the final $X$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$$1 \leq l_i \leq r_i \leq 10^9$- All values in the input are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
l_1 r_1
\vdots
l_{N} r_{N}
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
4
1 1
2 4
10 11
7 10
Output #1
8
The final $X$ is $(1,2,3,4,10,11,7,8,9,10)$.
The $1$-st, $2$-nd, $3$-rd, $4$-th, $7$-th, $8$-th, $9$-th, and $10$-th elements form a strictly increasing subsequence with the greatest length.
Input #2
4
1 1
1 1
1 1
1 1
Output #2
1
The final $X$ is $(1,1,1,1)$.
Input #3
1
1 1000000000
Output #3
1000000000
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。