問題一覧 > 通常問題

No.686 Uncertain LIS

レベル : / AI推定難易度 : 2525 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 23
作問者 : Pulmn / テスター : square1001
お気に入りにしたユーザー ProblemId : 1887 / 自分の提出
問題文最終更新日: 2026-06-25 02:36:02
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 190 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。