Welcome to Tokyo!

AtCoder
IDwtf22_day1_d
Time5000ms
Memory256MB
Difficulty
There are $M$ competitive programmers (kyopro-ers) numbered $1$ to $M$, who will visit Tokyo during the $N$ days starting today. Kyopro-er $i$ will stay in Tokyo from the $L_i$\-th day through the $R_i$\-th day ($1 \leq L_i \leq R_i \leq N$). Maroon is planning dinner parties with them. If a dinner party is held on the $x$\-th day ($1 \leq x \leq N$), he can make friends with all kyopro-ers $i$ with $L_i \leq x \leq R_i$. For each $k=1,2,\cdots,N$, solve the following problem. * Find the maximum number of kyopro-ers Maroon can make friends with if he holds exactly $k$ dinner parties. ## Constraints * $1 \leq N \leq 10^6$ * $1 \leq M \leq 10^6$ * $1 \leq L_i \leq R_i \leq N$ * All input values are integers. ## Input The 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$ [samples]
Samples
Input #1
3 3
1 1
1 2
3 3
Output #1
2
3
3

*   $k=1$: If he holds a party on the $1$\-st day, he can make friends with kyopro-ers $1$ and $2$.
*   $k=2$: If he holds a party on the $1$\-st and $3$\-rd days, he can make friends with kyopro-ers $1$, $2$, and $3$.
*   $k=3$: If he holds a party on the $1$\-st, $2$\-nd, and $3$\-rd days, he can make friends with kyopro-ers $1$, $2$, and $3$.
Input #2
4 4
1 1
2 2
3 3
4 4
Output #2
1
2
3
4
Input #3
3 6
1 1
1 2
1 2
2 3
2 3
3 3
Output #3
4
6
6
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
Output #4
7
11
12
13
14
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
API Response (JSON)
{
  "problem": {
    "name": "Welcome to Tokyo!",
    "description": {
      "content": "There are $M$ competitive programmers (kyopro-ers) numbered $1$ to $M$, who will visit Tokyo during the $N$ days starting today. Kyopro-er $i$ will stay in Tokyo from the $L_i$\\-th day through the $R_",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 5000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "wtf22_day1_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $M$ competitive programmers (kyopro-ers) numbered $1$ to $M$, who will visit Tokyo during the $N$ days starting today. Kyopro-er $i$ will stay in Tokyo from the $L_i$\\-th day through the $R_...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments