AtCoder Beginner Contest 127
翻译中…
Problem Statement
翻译中…
We have $N$ ID cards, and there are $M$ gates.
翻译中…
We can pass the $i$-th gate if we have one of the following ID cards: the $L_i$-th, $(L_i+1)$-th, ..., and $R_i$-th ID cards.
翻译中…
How many of the ID cards allow us to pass all the gates alone?
翻译中…
Constraints
翻译中…
- All values in input are integers.
$1 \leq N \leq 10^5$$1 \leq M \leq 10^5$$1 \leq L_i \leq R_i \leq N$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N M
L_1 R_1
L_2 R_2
\vdots
L_M R_M
翻译中…
Output
翻译中…
Print the number of ID cards that allow us to pass all the gates alone.
翻译中…
样例
Input #1
4 2
1 3
2 4
Output #1
2
Two ID cards allow us to pass all the gates alone, as follows:
- The first ID card does not allow us to pass the second gate.
- The second ID card allows us to pass all the gates.
- The third ID card allows us to pass all the gates.
- The fourth ID card does not allow us to pass the first gate.
Input #2
10 3
3 6
5 7
6 9
Output #2
1
Input #3
100000 1
1 100000
Output #3
100000
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。