308941: CF1601D. Difficult Mountain

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Difficult Mountain

题意翻译

## 题目描述 $n$ 个人相约去爬山。 山的初始攀登难度为 $d$。 每位登山者有两个属性:技巧 $s$ 和整洁度 $a$。 技巧为 $s$ 的登山者能登上攀登难度为 $p$ 的山当且仅当 $p\leq s$。 在一位整洁度为 $a$ 的登山者登上攀登难度为 $p$ 的山后,山的攀登难度会变为 $\max(p,a)$。 请给这些登山者指定一个爬山的先后顺序,最大化登上山的人数。 如果轮到一位登山者时他能登上山,则他一定会选择登山。 ## 输入格式 第一行两个整数 $n,d$($1\leq n\leq5\times10^5$,$0\leq d\leq10^9$)。 接下来 $n$ 行每行两个整数 $s_i,a_i$,描述第 $i$ 个登山者的信息。 ## 输出格式 一行一个整数,为登上山的人数的最大值。

题目描述

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.

输入输出格式

输入格式


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.

输出格式


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

输入输出样例

输入样例 #1

3 2
2 6
3 5
5 7

输出样例 #1

2

输入样例 #2

3 3
2 4
6 4
4 6

输出样例 #2

2

输入样例 #3

5 0
1 5
4 8
2 7
7 6
3 2

输出样例 #3

3

说明

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

题意翻译

## 题目描述 $n$ 个人相约去爬山。 山的初始攀登难度为 $d$。 每位登山者有两个属性:技巧 $s$ 和整洁度 $a$。 技巧为 $s$ 的登山者能登上攀登难度为 $p$ 的山当且仅当 $p\leq s$。 在一位整洁度为 $a$ 的登山者登上攀登难度为 $p$ 的山后,山的攀登难度会变为 $\max(p,a)$。 请给这些登山者指定一个爬山的先后顺序,最大化登上山的人数。 如果轮到一位登山者时他能登上山,则他一定会选择登山。 ## 输入格式 第一行两个整数 $n,d$($1\leq n\leq5\times10^5$,$0\leq d\leq10^9$)。 接下来 $n$ 行每行两个整数 $s_i,a_i$,描述第 $i$ 个登山者的信息。 ## 输出格式 一行一个整数,为登上山的人数的最大值。

加入题单

上一题 下一题 算法标签: