P26640 [AtCoder] Welcome to Tokyo!
NOI
题目描述

Problem Description

There are $ M $ competitive programmers numbered from $ 1 $ to $ M $, and they will visit Tokyo over the next $ N $ days. Competitive programmer $ i $ will stay in Tokyo from day $ L_i $ to day $ R_i $ ($1 \leq L_i \leq R_i \leq N$).

Maroon is planning a dinner party with them. If a dinner party is held on day $ x $ ($1 \leq x \leq N$), he can become friends with all competitive programmers $ i $ who satisfy $L_i \leq x \leq R_i$.

For each $k=1,2,\cdots,N$, solve the following problem:

  • Determine the maximum number of competitive programmers Maroon can become friends with if he holds exactly $ k $ dinner parties.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ L_1 $ $ R_1 $ $ L_2 $ $ R_2 $ $\vdots$ $ L_M $ $ R_M $

Output Format

Output $ N $ lines. The $ i $-th line should contain the answer for $ k=i $.

Sample Input and Output

Sample Input #1

3 3
1 1
1 2
3 3

Sample Output #1

2
3
3

Sample Input #2

4 4
1 1
2 2
3 3
4 4

Sample Output #2

1
2
3
4

Sample Input #3

3 6
1 1
1 2
1 2
2 3
2 3
3 3

Sample Output #3

4
6
6

Sample Input #4

20 15
15 19
1 8
6 11
3 11
11 17
6 6
16 20
7 11
11 14
2 19
1 3
7 7
6 19
14 15
15 15

Sample Output #4

7
11
12
13
14
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15

Notes/Hints

Constraints

  • $1 \leq N \leq 10^6$
  • $1 \leq M \leq 10^6$
  • $1 \leq L_i \leq R_i \leq N$
  • All values given in the input are integers.

Sample Explanation 1

  • $ k=1 $: If a dinner party is held on day 1, Maroon can become friends with competitive programmers 1 and 2.
  • $ k=2 $: If dinner parties are held on days 1 and 3, Maroon can become friends with competitive programmers 1, 2, and 3.
  • $ k=3 $: If dinner parties are held on days 1, 2, and 3, Maroon can become friends with competitive programmers 1, 2, and 3.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 1 1 1 2 3 3
样例输出
2 3 3