Add and Mex

AtCoder
IDabc272_e
Time2000ms
Memory256MB
Difficulty
You are given an integer sequence $A=(A_1,A_2,\ldots,A_N)$ of length $N$. Perform the following operation $M$ times: * For each $i\ (1\leq i \leq N)$, add $i$ to $A_i$. Then, find the minimum non-negative integer not contained in $A$. ## Constraints * $1\leq N,M \leq 2\times 10^5$ * $-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: $N$ $M$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
3 3
-1 -1 -6
Output #1
2
2
0

The $1$\-st operation makes the sequence $A$
$(-1 + 1, -1 +2 ,-6+3) = (0,1,-3).$
The minimum non-negative integer not contained in $A$ is $2$.
The $2$\-nd operation makes the sequence $A$
$(0 + 1, 1 +2 ,-3+3) = (1,3,0).$
The minimum non-negative integer not contained in $A$ is $2$.
The $3$\-rd operation makes the sequence $A$
$(1 + 1, 3 +2 ,0+3) = (2,5,3).$
The minimum non-negative integer not contained in $A$ is $0$.
Input #2
5 6
-2 -2 -5 -7 -15
Output #2
1
3
2
0
0
0
API Response (JSON)
{
  "problem": {
    "name": "Add and Mex",
    "description": {
      "content": "You are given an integer sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$. Perform the following operation $M$ times: *   For each $i\\ (1\\leq i \\leq N)$, add $i$ to $A_i$. Then, find the minimum non-n",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc272_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$.\nPerform the following operation $M$ times:\n\n*   For each $i\\ (1\\leq i \\leq N)$, add $i$ to $A_i$. Then, find the minimum non-n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments