#abc322c. C - Festival

C - Festival

Score : 250250 points

问题描述

AtCoder王国举行了一个持续 NN 天的节日。在这其中的 MM 天,即第 A1A_1 天、第 A2A_2 天、……、第 AMA_M 天将会燃放烟花。保证在节日的最后一天一定会燃放烟花。(换句话说,可以确保 AM=NA_M=N。)

对于每个 i=1,2,,Ni=1,2,\dots,N,解决以下问题:

  • 从第 ii 天开始算起,首次在第 ii 天或之后燃放烟花需要等待多少天?如果在第 ii 天就燃放了烟花,则视为等待 00 天。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

The AtCoder Kingdom holds a festival for NN days. On MM of these days, namely on the A1A_1-th, A2A_2-th, \dots, AMA_M-th days, fireworks will be launched. It is guaranteed that fireworks will be launched on the last day of the festival. (In other words, AM=NA_M=N is guaranteed.)

For each i=1,2,,Ni=1,2,\dots,N, solve the following problem.

  • How many days later from the ii-th day will fireworks be launched for the first time on or after the ii-th day? If fireworks are launched on the ii-th day, it is considered to be 00 days later.

Constraints

  • 1MN2×1051 \le M \le N \le 2 \times 10^5
  • 1A1<A2<<AM=N1 \le A_1 < A_2 < \dots < A_M = N
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \dots AMA_M

Output

Print NN lines.

The ii-th line (1iN)(1 \le i \le N) should contain an integer representing the number of days from the ii-th day until fireworks are launched for the first time on or after the ii-th day.

Sample Input 1

3 2
2 3

Sample Output 1

1
0
0

The kingdom holds a festival for 33 days, and fireworks are launched on the 22-nd and 33-rd days.

  • From the 11-st day, the first time fireworks are launched is the 22-nd day of the festival, which is 11 day later.
  • From the 22-nd day, the first time fireworks are launched is the 22-nd day of the festival, which is 00 days later.
  • From the 33-rd day, the first time fireworks are launched is the 33-rd day of the festival, which is 00 days later.

Sample Input 2

8 5
1 3 4 7 8

Sample Output 2

0
1
0
0
2
1
0
0

update @ 2024/3/10 01:42:21

}