Codeforces Round 751 (Div. 1)
D
Difficult Mountain
Codeforces
2700
原题
← CE →
翻译中…

A group of $n$ alpinists has just reached the foot of the mountain. The initial difficulty of climbing this mountain can be described as an integer $d$.

翻译中…

Each alpinist can be described by two integers $s$ and $a$, where $s$ is his skill of climbing mountains and $a$ is his neatness.

翻译中…

An alpinist of skill level $s$ is able to climb a mountain of difficulty $p$ only if $p \leq s$. As an alpinist climbs a mountain, they affect the path and thus may change mountain difficulty. Specifically, if an alpinist of neatness $a$ climbs a mountain of difficulty $p$ the difficulty of this mountain becomes $\max(p, a)$.

翻译中…

Alpinists will climb the mountain one by one. And before the start, they wonder, what is the maximum number of alpinists who will be able to climb the mountain if they choose the right order. As you are the only person in the group who does programming, you are to answer the question.

翻译中…

Note that after the order is chosen, each alpinist who can climb the mountain, must climb the mountain at that time.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $d$ ($1 \leq n \leq 500\,000$; $0 \leq d \leq 10^9$) — the number of alpinists and the initial difficulty of the mountain.

翻译中…

Each of the next $n$ lines contains two integers $s_i$ and $a_i$ ($0 \leq s_i, a_i \leq 10^9$) that define the skill of climbing and the neatness of the $i$-th alpinist.

翻译中…

Output

翻译中…

Print one integer equal to the maximum number of alpinists who can climb the mountain if they choose the right order to do so.

翻译中…

Note

翻译中…

In the first example, alpinists $2$ and $3$ can climb the mountain if they go in this order. There is no other way to achieve the answer of $2$.

翻译中…

In the second example, alpinist $1$ is not able to climb because of the initial difficulty of the mountain, while alpinists $2$ and $3$ can go up in any order.

翻译中…

In the third example, the mountain can be climbed by alpinists $5$, $3$ and $4$ in this particular order. There is no other way to achieve optimal answer.

翻译中…

样例

Input #1
3 2
2 6
3 5
5 7
Output #1
2
InputCopy OutputCopy
Input #2
3 3
2 4
6 4
4 6
Output #2
2
InputCopy OutputCopy
Input #3
5 0
1 5
4 8
2 7
7 6
3 2
Output #3
3
InputCopy OutputCopy
题目信息
题号
1601D
时间限制
2 s
内存限制
512 MB
标签
数据结构
动态规划
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。