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 



Sample input:
5 1
1 0 0 1 0


Sample output:
1 2 2 1 2

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
a=list(map(int,input().split()))

b=np.zeros(N,dtype=int)

for k in range(K):
    print(k,K)
    
    for i in range(N):
        l1=a[i]+1
        for j in range(l1):
            if(i+j<N):
                b[i+j]+=1
            if(i-j>=0 and (i-j)!=(i+j)):
                b[i-j]+=1
        
    for i in range(N):
        a[i]=b[i]
    b=np.zeros(N,dtype=int)
    
for i in range(N):
    print(a[i],"",end="")

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = map(int, input().split())
A_list = list(map(int, input().split()))

# print(N, K)
# print(A_list)

def update(input_list):
    result_list = np.zeros_like(input_list)
    for index, a in enumerate(input_list):
        index_from = max(0, index - a)
        index_to = min(N, index + a + 1)
        # print(f'index_from, index_to: {index_from, index_to}')
        result_list[index_from:index_to] = result_list[index_from:index_to] + 1
        # print(f'{index}: result_list: {result_list}')
    return result_list


for _ in range(K):
    A_list = update(A_list)
    # print(A_list)
print(A_list)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))

b=[0 for i in range(N)]

for k in range(K):
    print(k,K)
    
    for i in range(N):
        l1=a[i]+1
        for j in range(l1):
            if(i+j<N):
                b[i+j]+=1
            if(i-j>=0 and (i-j)!=(i+j)):
                b[i-j]+=1
        
    for i in range(N):
        a[i]=b[i]
    b=[0 for i in range(N)]
    
for i in range(N):
    print(a[i],"",end="")

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n,k = map(int, input().split())
a1 = list(map(int, input().split()))
a = np.asarray(a1, dtype=int)
if k<int(math.log(int(n))):
    for i in range(k):
        b = np.zeros(n, dtype=int)
        for j in range(n):
            mi = j-a[j]
            ma = j+a[j]
            if mi<0:
                mi = 0
            if ma>=n:
                ma = n-1
            b[mi:ma+1:]+=1
        a = b
    print(*a)
else:
    ans = np.zeros(n, dtype=int)
    ans+=n
    print(*ans)

Submission status: Wrong Answer

Solution code:
# 累積和で区間に操作ができる
import math
n,k=map(int,input().split())
A=list(map(int,input().split()))
kukan=[]
ans=[0]*n
for i in range(k):
    B=[0]*(n+1)#番兵は最後尾
    for j in range(n):
        l=max(0,j-A[j])
        r=min(j+A[j]+1,n)#右端の次の座標
        print(l,r)
        B[l]+=1
        B[r]-=1
    for j in range(n):
        B[j+1]+=B[j]
    B.pop()#比較するために要素数を揃える
    if A==B:#飽和したら終わり
        break
    A=B#AにBをコピー
for b in B:
    print(b)

Submission status: Wrong Answer

Solution code:
### import math
n,k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k):
    
    b = [0] * (n+1)
    #print(b)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(j+a[j]+1, n)
        b[l] += 1
        b[r] -= 1
        print(b)
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if(a == b):
        break
    a = b
        
ans = " ".join(map(str, a))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit

@njit
def update(a):
  n = len(a)
  b = np.zeros_like(a)
  for i,x in enumerate(a):
    l = max(0, i-x)
    r = min(n-1, i+x)
    b[i] += 1
    if r+1 < n:
      b[r+1] -=1
  b = np.cumsum(b)
  return b

n,k = map(int, input().split())
a = np.array(list(map(int, input().split())))

k = min(k, 100)

for _ in range(k):
  a = update(a)
print(' '.join(map(str,a)))

Submission status: Wrong Answer

Solution code:
# wa
import copy
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [1] * n
for _ in range(41):
    for i in range(n):
        light = 0
        for j in range(n):
            if i < j:
                if (j - a[j] - 0.5) < i:
                    light += 1
            else:
                if (j + a[j] + 0.5) > i:
                    light += 1
        b[i] = light
    a = copy.deepcopy(b)
print(a)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

n = 2 * 10**5
k = 2 * 10**5
a = [0] * n

for i in range(min(k, 50)):
    tmp = [0] * (n + 1)
    for j in range(n):
        tmp[max(0, j - a[j])] += 1
        tmp[min(n, j + a[j] + 1)] -= 1
    
    cnt = 0
    for j in range(n):
        cnt += tmp[j]
        a[j] = cnt

for i in range(n):
    print(a[i], end=' ')

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

n = 2 * 10**5
k = 2 * 10**5
a = [0] * n

for i in range(min(k, 450)):
    tmp = [0] * (n + 1)
    for j in range(n):
        tmp[max(0, j - a[j])] += 1
        tmp[min(n, j + a[j] + 1)] -= 1
    
    cnt = 0
    for j in range(n):
        cnt += tmp[j]
        a[j] = cnt

for i in range(n):
    print(a[i], end='')

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

n = 2 * 10**5
k = 2 * 10**5
a = [0] * n

for i in range(min(k, 50)):
    tmp = [0] * (n + 1)
    for j in range(n):
        tmp[max(0, j - a[j])] += 1
        tmp[min(n, j + a[j] + 1)] -= 1
    
    cnt = 0
    for j in range(n):
        cnt += tmp[j]
        a[j] = cnt

    print(a[0], a[-1])

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))


NL = []
for h in range(N):
    NL.append(h+1)
    

for k in range(K):
    maxL = []
    minL = []

    for i in range(N):
        maxL.append(0)
        minL.append(0)

    for i in range(5):
        maxL[i] = NL[i]+L[i]+0.5
        minL[i] = NL[i]-L[i]-0.5
    
    for i in range(5):
        x = 0
        for j in range(5):
            if i >= j:
                if NL[i] < maxL[j]:
                    x += 1
            else:
                if NL[i] > minL[j]:
                    x += 1
            L[i] = x


ANS=[str(a) for a in L]
ANS=" ".join(ANS)
print(ANS)

Submission status: Wrong Answer

Solution code:
# wa
import copy
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [1] * n
for _ in range(k):
    for i in range(n):
        light = 0
        for j in range(n):
            if i < j:
                if (j - a[j] - 0.5) < i:
                    light += 1
            else:
                if (j + a[j] + 0.5) > i:
                    light += 1
        b[i] = light
    a = copy.deepcopy(b)
print(a)

Submission status: Wrong Answer

Solution code:
# imos法
# 長さNの1次元配列において、「ある連続する区間に、ある数vを足す」という操作をK回繰り返した結果を高速で求める
# B リスト⇒辞書（その代わり累積和が遅くなる）

# 初期入力

import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
A = list(map(int, input().split()))


l =0
r =N
cumulative_sum =[0]*N
#操作数が電球の数より多いとき
if N <=K:
    A=[N]*N
# imos法
else:
    for j in range(K):
        B ={i:0 for i in range(N+1)}
        for i in range(N):
            index =A[i]
            if i-index <0:
                l=0
            else:
                l =i -index
            if i +index +1 >=N:
                r =N 
            else:
                r =i +index +1
            B[l] +=1 
            B[r] -=1
        #累積和(imos法) 
        from itertools import accumulate
        BB =list(B.values()) #辞書の値をリスト
        A =list(accumulate(BB))
        del A[-1]
        if sum(A) ==N*N:
            print(*A)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import jit
@jit
def op(A, n):
    B = np.zeros_like(A)
    for i, a in enumerate(A[:n]):
        B[max(i - a, 0)] += 1
        B[min(n - 1, a + i) + 1] -= 1
    return np.cumsum(B)

def main():
    n, k = list(map(int, input().split()))
    A = np.array(list(map(int, input().split())) + [0, ], dtype = np.int)
    if k >= np.log2(n) + 1:
        print(' '.join([str(n)] * n))
    else:
        for _ in range(k):
            A = op(A, n)
        print(' '.join(list(map(str, A[:n]))))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().rstrip().split())
an = list(map(int, sys.stdin.readline().rstrip().split()))


import numpy as np

t= min(k, 45)
print(t)


for k in range(t):
    bn = np.zeros(n, dtype=int)
    for i in range(n):
        bn[max(i - an[i], 0)] += 1
        print(max(i - an[i], 0), i+ an[i])
        if i+ an[i]+1 <n:
            bn[i+an[i]+1] -=1
        print(bn)
    an = np.cumsum(bn)


print(*an)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
lump = np.array(list(range(1, n+1)))
lump_low = lump - A - 0.5
lump_up = lump + A + 0.5

for l in range(k):
    count = np.zeros(n)
    x = np.array(range(1, n+1))
    for i in range(n):
        hantei = (lump_low[i] <= x) & (x<= lump_up[i])
        count += hantei
    lump = count
    lump_low = lump - count - 0.5
    lump_up = lump + count + 0.5

print(' '.join(map(str, lump)))

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().rstrip().split())
an = list(map(int, sys.stdin.readline().rstrip().split()))


import numpy as np

t= min(k, 45)
bn = np.zeros(n, dtype=int)

for k in range(t):
    for i in range(n):
        bn[max(i - an[i], 0)] += 1
        if i+ an[i] <n:
            bn[i+an[i]] -=1
    an = np.cumsum(bn)


print(*an)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)) and N >= 1000:
    if K > int(math.log(N)*15):
        K = int(math.log(N)*15)
    else:
        K = int(math.log(N))
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    if K > int(math.log(N)*15):
        K = int(math.log(N)*15)
    else:
        K = int(math.log(N))
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (*Ai)
    exit()
if(K > int(math.log2(N)+1)):
    mozi = str(N) + ' '
    print (mozi*N)
    exit()
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
print(*Ai)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
tu=0
td=0
if k>=30:
  a=[n]*n
else:
  for j in range(k):
    temp=[0]*n
    for i in range(n):
      td=max(i+1-a[i],1)
      temp[td-1]=temp[td-1]+1
      tu=min(i+1+a[i],n)
      if tu!=n:
        temp[tu]=temp[tu]-1
    a[0]=temp[0]
    for i in range(1,n):
      a[i]=a[i-1]+temp[i]
L=[str(t) for t in a]
L=" ".join(L)
print(L)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    K = int(math.log(N)*15)
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    K = int(math.log(N)*50)
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (*Ai)
    exit()
if(K > int(math.log(N)+1)):
    mozi = str(N) + ' '
    print (mozi*N)
    exit()
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
print(*Ai)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    K = int(math.log(N)*5)
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
lump = np.array(list(range(1, n+1)))
lump_low = lump - A - 0.5
lump_up = lump + A + 0.5

for l in range(k):
    count = np.zeros(n)
    for i in range(n):
        for j in range(n):
            if (lump_low[j]<=i<=lump_up[j]):
                count[i] += 1
    lump = count
    lump_low = lump - count - 0.5
    lump_up = lump + count + 0.5

print(' '.join(map(str, lump)))

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    K = int(math.log(N)*1.1)
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit

'''
N, K = map(int, input().split())
As = list(map(int, input().split()))
'''
N = 200000
K = 100000
As = [0] * N
#'''

@njit()
def update(A_array):
    before_csum = np.zeros(N+1, np.int32)
    for i, A in enumerate(A_array[:N]):
        before_csum[max(0, i-A)] += 1
        before_csum[min(N, i+A+1)] -= 1
    return np.cumsum(before_csum)
    
A_array = np.array(As + [0], dtype = np.int32)
for k in range(min(K, 50)):
    A_array = update(A_array)
    
print(*A_array.tolist()[:N])

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (*Ai)
    exit()
if(K> math.log(N)):
    mozi = str(N) + ' '
    print (mozi*N)
    exit()
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
print(*Ai)

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (*Ai)
    exit()
if(K> math.log(N)):
    mozi = str(N) + ' '
    print (mozi*N)
    exit()
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    if Ai[0] == N & Ai[-1] == N:
        break
print(*Ai)

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (*Ai)
    exit()
if(K> math.log(N)):
    print ('N '*10)
    exit()
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    if Ai[0] == N & Ai[-1] == N:
        break
print(*Ai)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    for x in range(k if k < 40 else 40):
        B = [0] * n
        for j in range(n):
            l = max(0, j - A[j])
            r = min(n - 1, j + A[j])
            B[l] += 1
            if r + 1 < n:
                B[r + 1] -= 1

        for x in range(1, n):
            B[x] += B[x - 1]
        A = B

    print(*A)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    for x in range(k if k < 20 else 20):
        B = [0] * n
        for j in range(n):
            l = max(0, j - A[j])
            r = min(n - 1, j + A[j])
            B[l] += 1
            if r + 1 < n:
                B[r + 1] -= 1

        for x in range(1, n):
            B[x] += B[x - 1]
        A = B

    print(*A)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (Ai)
    exit()
if(K> math.log(N)):
    print ([N]*N)
    exit()
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    print(Ai)
    if Ai[0] == N & Ai[-1] == N:
        break

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    K = int(math.log(N))+1
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
# imos法
# 長さNの1次元配列において、「ある連続する区間に、ある数vを足す」という操作をK回繰り返した結果を高速で求める
import numpy as np
# 初期入力
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
A = list(map(int, input().split()))


l =0
r =N
cumulative_sum =[0]*N
#操作数が電球の数より多いとき
if N <=K:
    B=[N]*N
# imos法
else:
    for j in range(K):
        B =[0]*(N+1)
        for i in range(N):
            index =A[i]
            if i-index <0:
                l=0
            else:
                l =i -index
            if i +index +1 >=N:
                r =N 
            else:
                r =i +index +1
            B[l] +=1 
            B[r] -=1
        #累積和(imos法) 
        cumulative_sum[0] =B[0]       
        for i in range(1,N):
            cumulative_sum[i] =cumulative_sum[i-1] +B[i]

        A =cumulative_sum
        if sum(A) ==N*N:
            print(*A)
            sys.exit(0)
        cumulative_sum =[0]*N
    
print(*A)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K > int(math.log(N)):
    K = int(math.log(N))
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
if K >= 50:
    K = int(math.log(K))
# if K >= 1000 and N / 2 + 1 < K:
#     K = int(math.sqrt(N))
# if K >= 50:
#     K = 50
A_list = list(map(int, input().split()))

A_New_list = [0 for i in range(N)]
for k in range(K):
    for i in range(N):
        if i - A_list[i] <= 0:
            A_New_list[0] += 1
        else:
            A_New_list[i - A_list[i]] += 1
        if i + A_list[i] + 1 < N:
            A_New_list[i + A_list[i] + 1] -= 1
    for i in range(1,N):
        A_New_list[i] += A_New_list[i-1]
    A_list = A_New_list
    if k != K - 1:
        A_New_list = [0 for n in range(N)]
A_New_list = [str(a) for a in A_New_list]
ans = " ".join(A_New_list)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (Ai)
    exit
if(K> math.log(N)):
    k = int(math.log(N))
for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    print(Ai)
    if Ai[0] == N & Ai[-1] == N:
        break

Submission status: Wrong Answer

Solution code:
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (Ai)
    exit
# if(K>int(N/2))

for i in range(41):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    print(Ai)
    if Ai[0] == N & Ai[-1] == N:
        break

Submission status: Wrong Answer

Solution code:
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])
if(Ai == [0]*N):
    print (Ai)
    exit
# if(K>int(N/2))

for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    print(Ai)
    if Ai[0] == N & Ai[-1] == N:
        break

Submission status: Wrong Answer

Solution code:
import sys
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
if n >=1000 and k >math.log(n):
    for q in range(len(ls)):
        print(len(ls),end=" ")
    sys.exit()
if k >= len(ls):
    for q in range(len(ls)):
        print(len(ls),end=" ")
    sys.exit()
for _ in range(k):
    new = [0]*n
    for i in range(n):
        p = 0
        for l in range(1,max(n-i,i+1)):
            if i+l >= 0 and i+l <n:
                if ls[i+l] >= l:
                    p += 1
            if i-l >= 0 and i-l <n:
                if ls[i-l] >= l:
                    p += 1
        new[i] = p+1
    ls = new
print(*ls)

Submission status: Wrong Answer

Solution code:
import sys
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
if n >=1000 and k >n/(math.log10(n))**(math.log10(n)):
    for q in range(len(ls)):
        print(len(ls),end=" ")
    sys.exit()
if k >= len(ls):
    for q in range(len(ls)):
        print(len(ls),end=" ")
    sys.exit()
for _ in range(k):
    new = [0]*n
    for i in range(n):
        p = 0
        for l in range(1,max(n-i,i+1)):
            if i+l >= 0 and i+l <n:
                if ls[i+l] >= l:
                    p += 1
            if i-l >= 0 and i-l <n:
                if ls[i-l] >= l:
                    p += 1
        new[i] = p+1
    ls = new
print(*ls)

Submission status: Wrong Answer

Solution code:
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,40)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(*l)

Submission status: Wrong Answer

Solution code:
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])

for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        if d == N:
            Bi[i] = N
            pass
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    if Ai == [N]*N:
        break
print(Ai)

Submission status: Wrong Answer

Solution code:
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,20)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(*l)

Submission status: Wrong Answer

Solution code:
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,99)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(l)

Submission status: Wrong Answer

Solution code:
stdin = [input() for i in range(2)]
line = stdin[0].split(' ')
N = int(line[0])
K = int(line[1])
line = stdin[1].split(' ')
Ai = [0]*N
for i in range(len(line)):
    Ai[i] = int(line[i])

for i in range(K):
    Bi = [1]*N
    for i, d in enumerate(Ai):
        for j in range(1,d+1):
            if i-j >=0:
                Bi[i-j] +=1
            if i+j <N:
                Bi[i+j] +=1
    Ai = Bi
    if Ai == [N]*N:
        break
print(Ai)

Submission status: Wrong Answer

Solution code:
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,20)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(l)

Submission status: Wrong Answer

Solution code:
import copy
import sys
import math

def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0] * n

    k_max = 1 + math.ceil(math.log10(n))

    for i in range(min(k, k_max)):
        for j in range(n):
            l = max(0, j-A[j]) #座標iの電球が照らす範囲の左端
            r = min(n-1, j+A[j]) #座標iの電球が照らす範囲の右端
            B[l] += 1
            if (r+1 < n):
                B[r+1] -= 1 # 後ほど累積和にしたときに、照らす範囲の右端より外には影響が及ばないようにあらかじめ1引いておく

        for j in range(n-1):
            B[j+1] += B[j]

        A = copy.deepcopy(B)
        B = [0] * n

    print(*A)

if __name__ == '__main__':
    main()