#P6349. [PA 2011] Kangaroos
[PA 2011] Kangaroos
Description
You are given a sequence of length . The -th element is an interval .
There are queries. Each query gives . Find the longest subarray (i.e., a contiguous segment of this sequence) such that every interval in this subarray intersects with . Output the length of this longest subarray.
Input Format
The first line contains two integers .
The next lines each contain two integers .
The next lines each contain two integers , describing one query.
Output Format
Output lines. Each line contains one integer, the answer to the corresponding query.
3 3
2 5
1 3
6 6
3 5
1 10
7 9
2
3
0
Hint
Constraints: , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号