A14580 | Difficult Mountain
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted