QOJ.ac

QOJ

Limite de temps : 4 s Limite de mémoire : 32 MB Points totaux : 10

#10390. 袋鼠 [A]

Statistiques

Byteasar 对野生动物摄影很感兴趣,他正在计划一次澳大利亚之旅。他已经开始准备拍摄袋鼠的摄影器材,并需要决定携带哪些物品。他的器材包括一系列具有不同视角和对焦能力的摄影镜头。拍摄动物(如袋鼠)的最佳画质是在相机与动物的距离处于镜头的最佳工作范围内时获得的。

Byteasar 的旅程经过一系列野生动物观察和摄影的接入点。澳大利亚的向导为 Byteasar 提供了这些观察点的详细描述,特别是袋鼠可能出现的距离范围。

显然,Byteasar 庞大的镜头收藏中并非所有镜头都能装入行李,因此必须做出一些取舍。由于 Byteasar 希望尽量减少更换镜头的次数,他想为每个镜头找到该镜头适用的最长连续观察点序列。如果一个观察点预期的距离范围内存在某个距离处于该镜头的最佳工作范围内,则称该镜头适用于该观察点。

输入格式

输入的第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 50\,000$, $1 \le m \le 200\,000$),其中 $n$ 是旅程中观察点的数量,$m$ 是 Byteasar 收藏的镜头数量。

接下来的 $n$ 行描述了 Byteasar 旅程中的野生动物观察和摄影接入点。每行包含两个整数 $a_{i}$ 和 $b_{i}$ ($1 \le a_{i} \le b_{i} \le 10^{9}$),表示在第 $i$ 个观察点,袋鼠可能出现在距离 $a_{i}$ 到 $b_{i}$ bytean 英尺的范围内(包含边界)。

接下来的 $m$ 行描述了镜头。每行包含两个整数 $c_{j}$ 和 $d_{j}$ ($1 \le c_{j} \le d_{j} \le 10^{9}$),表示第 $j$ 个镜头最适合拍摄距离相机 $c_{j}$ 到 $d_{j}$ bytean 英尺范围内的袋鼠(包含边界)。

输出格式

输出应包含 $m$ 行,每行恰好一个整数。第 $j$ 行输出表示第 $j$ 个镜头在 Byteasar 的旅程中适用的最长连续观察点序列的长度。镜头的编号按照输入文件中的顺序排列。

样例

输入 1

3 3
2 5
1 3
6 6
3 5
1 10
7 9

输出 1

2
3
0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.