#P1840. Color the Axis

Color the Axis

Description

On a number line there are nn points, namely 1,2,,n1, 2, \ldots, n. Initially, all points are colored black. Then we perform mm operations; in the ii-th operation, the points in [li,ri][l_i,r_i] are painted white. Output the number of black points remaining after each operation.

Input Format

The first line contains nn and mm. Each of the next mm lines contains two integers lil_i, rir_i.

Output Format

Output mm lines, where each line is the number of black points remaining after the corresponding operation.

10 3
3 3
5 7
2 8
9
6
3

Hint

  • For 30% of the testdata, 1n20001\le n\le 2000, 1m20001\le m\le 2000.
  • For 100% of the testdata, 1lirin2×1051\le l_i\le r_i\le n\le 2\times 10^5, 1m2×1051\le m\le 2\times 10^5.

Translated by ChatGPT 5