#abc272e. E - Add and Mex

E - Add and Mex

Score : 500500 points

## 问题描述

给定一个长度为 $N$ 的整数序列 $A=(A_1,A_2,\ldots,A_N)$。

执行以下操作 $M$ 次:

- 对于每个 $i\ (1\leq i \leq N)$,将 $i$ 加到 $A_i$ 上。然后,找出不在 $A$ 中的最小非负整数。

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

Problem Statement

You are given an integer sequence A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N) of length NN.

Perform the following operation MM times:

  • For each i (1iN)i\ (1\leq i \leq N), add ii to AiA_i. Then, find the minimum non-negative integer not contained in AA.

Constraints

  • 1N,M2×1051\leq N,M \leq 2\times 10^5
  • 109Ai109-10^9\leq A_i\leq 10^9
  • All values in the input are integers.

Input

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

NN MM

A1A_1 A2A_2 \ldots ANA_N

Output

Print MM lines.

The ii-th (1iM)(1\leq i \leq M) line should contain the minimum non-negative integer not contained in AA after the ii-th operation.

Sample Input 1

3 3
-1 -1 -6

Sample Output 1

2
2
0

The 11-st operation makes the sequence AA

(1+1,1+2,6+3)=(0,1,3).(-1 + 1, -1 +2 ,-6+3) = (0,1,-3).

The minimum non-negative integer not contained in AA is 22.

The 22-nd operation makes the sequence AA

(0+1,1+2,3+3)=(1,3,0).(0 + 1, 1 +2 ,-3+3) = (1,3,0).

The minimum non-negative integer not contained in AA is 22.

The 33-rd operation makes the sequence AA

(1+1,3+2,0+3)=(2,5,3).(1 + 1, 3 +2 ,0+3) = (2,5,3).

The minimum non-negative integer not contained in AA is 00.

Sample Input 2

5 6
-2 -2 -5 -7 -15

Sample Output 2

1
3
2
0
0
0

update @ 2024/3/10 11:27:56