Problem:
Score : 500 points

Problem Statement

We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.

Each bulb has a non-negative integer parameter called intensity.
When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.
Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:

For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.

Find the intensity of each bulb after the K operations.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq K \leq 2 \times 10^5

0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

Print the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:

A{'}_1 A{'}_2 \ldots A{'}_N

Sample Input 1

5 1
1 0 0 1 0

Sample Output 1

1 2 2 1 2

Initially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.
Similarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.

Sample Input 2

5 2
1 0 0 1 0

Sample Output 2

3 3 4 4 3

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

const int MAXSSTN = 200010;
class StarrySkyTree{
public:
  int size=0;
  int depth=0; // the depth of the tree
  int best=0;  // the index of maximum element
  int start=0; // the initial index of inputs
  long long dat_add[3 * MAXSSTN];
  long long dat[3 * MAXSSTN];
  StarrySkyTree(int n){
    size=n;
    while((1<<depth)<n)depth++;
    start=(1<<depth)-1;
    for(int i=start;i<(1<<(depth+1));i++){
      dat[i]=-1e15;
    }
  }
  StarrySkyTree(int n,long long* v){
    size=n;
    while((1<<depth)<n)depth++;
    start=(1<<depth)-1;
    for(int i=start;i<(1<<(depth+1));i++){
      if(i<start+n)
	dat[i]=v[i-start];
      else
	dat[i]=-1e15;
    }
    for(int i=start;i<start+n;i++){
      int tmp=i;
      while(par(tmp)!=-1){
	dat[par(tmp)]=max(dat[tmp],dat[(tmp+1)/2*4-1-tmp]);
	tmp=par(tmp);
      }
    }
    int i=0;
    while(i<start)i=(dat[i]==dat[2*i+1])?2*i+1:2*i+2;
    best=i-start;
  }
  long long max_element(int a, int b){ return max_element(a, b, 0, 0, (1<<depth)); }
  void add(int s, int t, long long x){ add(s, t, 0, 0, (1<<depth), x); }
  void add(int i, long long x){ add(i, i + 1, 0, 0, (1<<depth), x); }

  int par(int i){
    if(i==0)
      return -1;
    return (i-1)/2;
  }

  void clear(){
    
    REP(i,3*MAXSSTN){
      dat_add[i]=0;
      dat[i] = 0;
    }
    for(int i=start;i<(1<<(depth+1));i++){
      dat[i]=-1e15;
    }
  }

  void update(int d,long long x){
    int i=d+start;
    dat[i]=x;
    while(par(i)!=-1){
      dat[par(i)]=max(dat[i]+dat_add[i],dat[(i+1)/2*4-1-i]+dat_add[(i+1)/2*4-1-i]);
      i=par(i);
    }
    i=0;
    while(i<start){
      i=(dat[i]==dat[2*i+1])?2*i+1:2*i+2;
    }
    best=i-start;
  }
  void dump(){
    cerr<<"SegTree:"<<endl;
    for(int i=0;i<depth+1;i++){
      for(int j=0;j<(1<<i);j++)
	cerr<<dat[j+(1<<i)-1]<<" ";
      cerr<<endl;
    }
    cerr<<endl;
    cerr<<"SegTree lazy addition:"<<endl;
    for(int i=0;i<depth+1;i++){
      for(int j=0;j<(1<<i);j++)
	cerr<<dat_add[j+(1<<i)-1]<<" ";
      cerr<<endl;
    }
    cerr<<endl;
  }
private:
  long long max_element(int a, int b, int k, int l, int r){
    if(b <= l || r <= a) return -1e15;
    if(a <= l && r <= b) return dat[k] + dat_add[k];

    long long vl = max_element(a, b, k * 2+1, l, (l + r) / 2);
    long long vr = max_element(a, b, k * 2+2, (l + r) / 2, r);
    return max(vl, vr) + dat_add[k];
  }
  void add(int a, int b, int k, int l, int r, long long x){
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      dat_add[k] += x;
    }else{
      add(a, b, k * 2+1, l, (l + r) / 2, x);
      add(a, b, k * 2+2, (l + r) / 2, r, x);
      dat[k] = max(dat[k * 2+1] + dat_add[k * 2+1], dat[k * 2 + 2] + dat_add[k * 2 + 2]);
    }
  }
};

int n,k;
int a[200000];
bool ignorearr[200000];
LL ig_norecnt = 0;

int main(){
  cin>>n>>k;
  REP(i,n){cin>>a[i];
  ignorearr[i]=false;}
  if(k >= 41){
    REP(i,n)cout<<n<<" ";
    cout<<endl;
    return 0;
  }

  StarrySkyTree sst(n);
  REP(i,k){
    REP(j,n)sst.update(j,ig_norecnt);
    REP(j,n){
      if(!ignorearr[j])
        sst.add(max(0,j-a[j]),min(n-1,j+a[j])+1,1);
    }
    REP(j,n){
      if(a[j] != n)
        a[j]=sst.max_element(j,j+1);
      if(!ignorearr[j] && max(0,j-a[j])==0 && min(n-1,j+a[j])+1 == n){
        ignorearr[j] = true;
        ig_norecnt++;
      }
    }
    sst.clear();
  }

  REP(i,n)cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}