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 F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<int,int> P;

int N=1<<18;
class StarrySkyTree{
public:
  int Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,int x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  int getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return MAX;if(a<=l&&r<=b)return Mi[k]+A[k];
    int left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return min(left,right)+A[k];
  }
};

StarrySkyTree t;

void Main() {
  int n,m;
  cin >> n >> m;
  int a[n];
  rep(i,n) R a[i];
  vector<P> v;
  rep(i,n) {
    if(a[i]!=n) v.pb(P(i,a[i]));
    //v.pb(P(i,0));
  }
  rep(k,m) {
    t.init();
    rep(i,v.size()) {
      int x=v[i].F,y=v[i].S;
      t.add(max(0,x-y),min(n,x+y+1),1);
    }
    t.add(0,n,n-v.size());
    vector<P> g;
    rep(i,v.size()) {
      int x=v[i].F;
      int y=t.getMin(x,x+1);
      if(y!=n) g.pb(P(x,y));
    }
    v=g;
    if(!v.size()) {
      rep(i,n) {
        if(i) cout << " ";
        cout << t.getMin(i,i+1);
      }
      ln;
      return;
    }
  }
  rep(i,n) {
    if(i) cout << " ";
    cout << t.getMin(i,i+1);
  }
  ln;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}