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: Runtime Error)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll INF = 1e9+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

//最大公約数
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

//最小公倍数
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

//素因数分解
map<int,int> prime_factor(ll n,map<int,int> &res){
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1){
        if(res[n]==0){
            res[n]=1;
        }else{
            res[n]++;
        }
    }
    return res;
}

//約数列挙
vector<ll> divisor(ll n){
    vector<ll> a;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            a.push_back(i);
            if(i*i!=n){
                a.push_back(n/i);
            }
        }
    }
    SORT(a);
    return a;
}

//拡張ユークリッドの互除法
int extgcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }else{
        int d=extgcd(b,a%b,y,x);
        y-=a/b*x;
        return d;
    }
}

//素数判定
void sieve(int n,vector<bool> &is_prime) {
	is_prime[0]=false;
	is_prime[1]=false;
	for (int i = 2; i * i <= n; i++) {
		if (is_prime[i]) {
			for (int j = i * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return;
}

//繰り返し2乗法
ll mod_pow(ll x,ll n,ll mod){
    x%=mod;
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

//mod　m での a の逆元
int mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

vector<ll> factrial, inverse;

//nCkの前計算
void init(ll n,ll m){
    factrial.resize(n+1);
    inverse.resize(n+1);
    factrial[0]=1;
    inverse[0]=1;
    for(ll i=1;i<=n;i++){
        factrial[i]=factrial[i-1]*i%m;
        inverse[i]=mod_inverse(factrial[i],m);
    }
}

//nCk
ll nCk(ll n,ll k,ll m){
    if(n<0||k<0||n<k){
        return 0;
    }
    return factrial[n]*inverse[k]%m*inverse[n-k]%m;
}

int mod=1e9+7;

struct StarrySky{
  static const int MAX_N = 1 << 17;
  int datm[2*MAX_N],data[2*MAX_N],n;
  StarrySky(){}
  StarrySky(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<n*2;i++) datm[i]=data[i]=0;
  }
  void add(int a,int b,int x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      data[k]+=x;
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
    datm[k]=max(datm[k*2+1]+data[k*2+1],datm[k*2+2]+data[k*2+2]);
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return 0;
    if(a<=l&&r<=b) return datm[k]+data[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr)+data[k];
  }
  void add(int a,int b,int x){
    add(a,b,x,0,0,n);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

int main(){
    int n,k;
    cin>>n>>k;
    StarrySky ss(n);
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        ss.add(max(0,i-a[i]),min(n,i+a[i]+1),1);
    }
    rep(i,n){
        int x=ss.query(i,i+1);
        ss.add(max(0,i-a[i]),min(n,i+a[i]+1),-1);
        ss.add(max(0,i-x),min(n,i+x+1),1);
    }
    rep(i,n){
        cout<<ss.query(i,i+1)<<endl;
    }
}