IBMOA #63
Process Execution Time
估计中等可在线判题
考点(AI 标注)前缀和区间
Each process runs during the integer closed interval [start[i],end[i]]. Find the number of integer moments at which at least one process is running. The source statement body is truncated; the original example explicitly merges overlapping intervals into [1,6], counting 6, then adds [8,10], counting 3, and the union-length rule is recovered from that explanation.
输入格式
The first line contains n, followed by n lines of start end. Full original bounds: 1≤n≤200000, 1≤start≤end≤10^9.
输出格式
Output one integer, the answer.
样例 1
输入:
3
1 5
2 6
8 10
输出:
9
样例 2
输入:
1
5 5
输出:
1
样例 3
输入:
3
3 8
1 10
10 10
输出:
10
样例说明
The outputs of the three public examples are, in order: 9; 1; 10. These answers were verified by independent enumeration or direct simulation.