No.686 Uncertain LIS
タグ : / 解いたユーザー数 23
作問者 :
Pulmn
/ テスター :
Problem Statement
Find the maximum possible length of the longest increasing subsequence of a sequence $A$ satisfying the following condition. Note that sequence indices are 1-indexed.
Condition: The length of the sequence $A$ is $N$, and for every $i$ satisfying $1\le i\le N$, $A_i$ is an integer and $L_i\le A_i\le R_i$ holds.
* The longest increasing subsequence of $A$ means the longest subsequence among the strictly increasing subsequences of $A$.
Input
$N$ $L_1$ $R_1$ $L_2$ $R_2$ $\vdots$ $L_N$ $R_N$
$1\le N\le 10^5$
$1\le L_i\le R_i\le 10^5$ $(1\le i\le N)$
Output
Output the maximum possible length of the longest increasing subsequence. Print a newline at the end.
Sample
Sample 1
Input
5 3 5 1 3 2 7 1 2 2 3
Output
3
For example, if $A=\{3,1,2,2,3\}$, the longest increasing subsequence is $\{1,2,3\}$, and the length of the longest increasing subsequence is $3$.
Sample 2
Input
1 1 100000
Output
1
Sample 3
Input
5 1 1 2 2 3 3 4 4 5 5
Output
5
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。