#P1496. 火烧赤壁

火烧赤壁

Description

Given the start and end of each burning segment, please compute the total length of the burning positions.

Input Format

The first line contains an integer nn, indicating the number of fire reports.
Then follow nn lines; each line contains two integers a,ba, b, denoting the start and end of a burning segment (Note: left-closed, right-open).

Output Format

Output a single line with one integer representing the answer.

3
-1 1
5 11
2 9
11

Hint

Constraints

For all test points, it is guaranteed that 1n2×1041 \leq n \leq 2 \times 10^4, 231a<b<231-2^{31} \leq a < b \lt 2^{31}, and the answer is less than 2312^{31}.

Translated by ChatGPT 5