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 math

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

for i in range(min(math.ceil(math.log(N)+5), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(min(math.ceil(math.log(N)), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(min(math.ceil(math.log(N)), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

  print(" ".join(list(map(str, A))))

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if(n == 0):
    print(x)
elif(n == 100):
    ff = 101-x
    gg = x
    if(ff < gg):
        print(101)
    else:
        print(0)
else:
    p = list(map(int, input().split()))
    if(not(x in p)):
        print(x)
    else:
        m = [i for i in range(1, 101)]
        for i in range(len(m)):
            if(m[i] in p):
                m[i] = 10000
            else:
                m[i] = abs(x-m[i])
        print(m.index(min(m))+1)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))

def culc(L):
    subL=[0]*(n+1)

    for i in range(n):
        temp=L[i]
        bottom=max(i-temp,0)
        top=min(i+temp,n-1)

        subL[bottom]+=1
        subL[top+1]-=1
    
    resL=[0]*n
    resL[0]=subL[0]
    for i in range(1,n):
        resL[i]=resL[i-1]+subL[i]

    return resL

for i in range(min(k,20)):
    A=culc(A)

print(*A)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,k = map(int,input().split())
l = [int(a) for a in input().split()]
for _ in range(min(k,50)):
    a = [0] * (N+1)
    for i,x in enumerate(l):
        a[max(0,i-x)] += 1
        a[min(i+x+1,N)] -= 1
    a_l = np.cumsum(np.array(a))[:-1].tolist()
print(' '.join(map(str, a_l)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))

def culc(L):
    subL=[0]*(n+1)

    for i in range(n):
        temp=L[i]
        bottom=max(i-temp,0)
        top=min(i+temp,n-1)

        subL[bottom]+=1
        subL[top+1]-=1
    
    resL=[0]*n
    resL[0]=subL[0]
    for i in range(1,n):
        resL[i]=resL[i-1]+subL[i]

    return resL

for i in range(min(k,45)):
    A=culc(A)

print(A)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))

def culc(L):
    subL=[0]*(n+1)

    for i in range(n):
        temp=L[i]
        bottom=max(i-temp,0)
        top=min(i+temp,n-1)

        subL[bottom]+=1
        subL[top+1]-=1
    
    resL=[0]*n
    resL[0]=subL[0]
    for i in range(1,n):
        resL[i]=resL[i-1]+subL[i]

    return resL

for i in range(min(k,50)):
    A=culc(A)

print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k = map(int,input().split())
A = list(map(int,input().split()))
imos = [0]*(n+1)
for j in range(k):
    if j==0:
        arr = A
    else:
        arr = imos
    imos = [0]*(n+1)
    for i,a in enumerate(arr):
        imos[max(i-a, 0)] += 1
        imos[min(i+a+1, n)] -= 1
    imos = list(np.cumsum(imos))[:-1]
    if set(imos)=={n}:
        break
print(imos)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit

N,K = map(int, input().split())
A = np.array(list(map(int, input().split())))

@njit
def main(N, K, A):
  for _ in range(min(K, 42)):
    A_ = np.zeros_like(A)
    for n in range(N):
      A_[max(0, n - A[n])] += 1
      if n + A[n] + 1  < N:
        A_[n + A[n] + 1] -= 1
    A = A_.cumsum()
        
  return A

print(main(N, K, A))

Submission status: Wrong Answer

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

A = list(map(int, input().split()))

L = [0]*N

for k in range(K):
  for n in range(N):
    a = A[n]
    for i in range(2*a+1):
      p = n - a + i
      if 0 <= p < N:
        L[p] += 1
  A = L
  L = [0]*N
  if k > 41:
    break
print(A)

Submission status: Wrong Answer

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

L = [0]*N

for k in range(K):
  for n in range(N):
    a = A[n]
    for i in range(2*a+1):
      p = n - a + i
      if 0 <= p < N:
        L[p] += 1
  A = L
  L = [0]*N
  if k > 41:
    break
    
print(A)

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(42):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        if min(a) == n:
            break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(42):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        if min(a) == n:
            break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


def main():
    number, operations = [int(x) for x in input().split()]
    dists = [int(x) for x in input().split()]

    number = 10 ** 5 * 2
    dists = [0] * number
    operations = number

    for ope_count in range(operations):
        temp = [0] * (number + 1)
        for i, v in enumerate(dists):
            left = max(i - v, 0)
            right = min(i + v + 1, number)
            temp[left] += 1
            temp[right] -= 1
        dists = accumulate(temp)
        if len(set(dists)) == 1:
            break

    print(*list(dists)[:-1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A = list(map(int, input().split()))

L = [0]*N

for k in range(K):
  for n in range(N):
    a = A[n]
    for i in range(2*a+1):
      p = n - a + i
      if 0 <= p < N:
        L[p] += 1
  A = L
  L = [0]*N

print(A)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
zero=[0 for i in range(N+1)]
for t in range(K):
  for i in range(N):
    l=max(0,i-A[i])
    r=min(N,i+A[i]+1)
    imos[l]+=1
    imos[r]-=1
  for i in range(0,N):
    imos[i+1]+=imos[i]
    A[i]=imos[i]
  imos=zero
  if len(set(A))==1 and (N in set(A)):
    break
for i in range(N):
  A[i]=str(A[i])
ans=" ".join(A)
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
zero=[0 for i in range(N+1)]
ANS=[str(N)]*N
if K>=40:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    imos=zero
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
def conv(A,N):
    #A(座標iの電灯の強さリスト)からB(座標iを照らしている電灯数)への変換
    #累積和を使う
    B_=[0 for n in range(N)]
    for n in range(1,N+1):
        il_min=max(n-A[n-1],1)
        il_max=min(n+A[n-1],N)
        B_[il_min-1]+=1
        if il_max<=N-1:
            B_[il_max]-=1

    B=[0 for n in range(N)]
    B[0]=B_[0]
    for n in range(1,N):
        B[n]=B[n-1]+B_[n]
    return B

def main():
    #input
    N,K=map(int,input().strip().split())
    A=list(map(int,input().strip().split()))
    
    if K>45:
        return [N for n in range(N)]
    else:
        for k in range(K):
            B=conv(A,N)
            if A==B:
                break
            else:
                A=B
        return " ".join(list(map(str,A)))

if __name__=="__main__":
    print(main())

Submission status: Wrong Answer

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

i = 0
while i in range(0, K):
    B = [0 for _ in range(N)]

    for i in range(0,N):
        f = max(0, i - A[i])
        t = min(N-1, i + A[i])
        #for j in range(max(0, f), min(N, t)+1):
        #    B[j] += 1
        B[f] += 1
        if t+1 < N:
            B[t+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    if A == B:
        i = K
    A = B
    i += 1

print(" ".join(map(lambda a: str(a), A)))

Submission status: Wrong Answer

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

if (K >= N):
  print([N] * N)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=[str(N)]*N
if K>=30:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

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

def proc():
    global A
    B = [0 for _ in range(N)]

    for i in range(0,N):
        f = max(0, i - A[i])
        t = min(N-1, i + A[i])
        #for j in range(max(0, f), min(N, t)+1):
        #    B[j] += 1
        B[f] += 1
        if t+1 < N:
            B[t+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    A = B

i = 0
while i in range(0, K):
    proc()
    if all(map(lambda a: a == N, A)):
        i = K

print(" ".join(map(lambda a: str(a), A)))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=50:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
n,k=[int(_) for _ in input().split()]
A=[int(_) for _ in input().split()]
_A=[0 for i in range(n+1)]
for i in range(k):
    for j in range(n+1):
        _A[j]=0
    for j in range(n):
        if j-A[j]>0:
            _A[j-A[j]]+=1
        else:
            _A[0]+=1
        if j+A[j]+1<n-1:
            _A[A[j]+j+1]-=1
    for j in range(1,n):
        _A[j]+=_A[j-1]
        
    for j in range(n):
        A[j]=_A[j]
    
    if sum(A)==n*n:
        break

for i in range(n):
    print(A[i],end=" ")
print()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
ans = [0 for i in range(n)]

for j in range(k):
  ls = [0 for i in range(n)]
  rs = [0 for i in range(n)]
  
  for i in range(n):
    l = max(i - a[i], 0)
    r = min(i + a[i], n-1) + 1
    ls[l] += 1
    if r < n:
      rs[r] += 1

  for i in range(1, n):
    ls[i] += ls[i-1]
    rs[i] += rs[i-1]

  for i in range(n):
    ans[i] = ls[i] - rs[i]
  
  if len(set(ans)) == 1 and ans[0] == n:
    break

  a = ans
  
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=30:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=30:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mina = 0
    for i in range(K):
        B = [0]*N
        for j in range(N):
            if j-A[j] >= 0:
                B[j-A[j]] += 1
            else:
                B[0] += 1
            if j+A[j]+1 < N:
                B[j+A[j]+1] -= 1
            # print(j,B)
        A = list(accumulate(B[:]))
        mina = mina*2+1
        if mina > 2*N:
            break
    print(*A)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mina = 0
    for i in range(K):
        B = [0]*N
        for j in range(N):
            if j-A[j] >= 0:
                B[j-A[j]] += 1
            else:
                B[0] += 1
            if j+A[j]+1 < N:
                B[j+A[j]+1] -= 1
            # print(j,B)
        A = list(accumulate(B[:]))
        mina = mina*2+1
        if mina >= N:
            break
    print(*A)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mina = 0
    for i in range(K):
        B = [0] * N
        for j in range(N):
            B[max(j-A[j],0)] += 1
            if j+A[j]+1 < N:
                B[j+A[j]+1] -= 1
            # print(j,B)
        A = list(accumulate(B[:]))
        mina = mina*2+1
        if mina >= N:
            break
    print(*A)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

#old_ai = ai
cnt = 0

aij = [[0 for i in range(n)] for j in range(2)]
aij[0] = ai

while 1 == 1:
    li = [0]*(n+1)
    for i in range(n):
        li[max(0,i-aij[0][i])] += 1
        li[min(n,i+1+aij[0][i])] -= 1
        #print(li)
    #print(li)
    tmp = 0
    for i in range(n):
        if i == 0:
            aij[1][i] = li[i]
            tmp += aij[1][i]
        else:
            aij[1][i] = li[i] + aij[1][i-1]
            tmp += aij[1][i]
    #print(rui)
    if aij[1] == aij[0]:
        print(*aij[1])
        exit()
        break
    cnt += 1
    if cnt == k:
        print(*aij[1])
        exit()
    aij[0] = aij[1]

Submission status: Wrong Answer

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

count = [0] * N

for _ in range(0, K):
  count = [0] * N
  for i in range(0, N):
    a_min = int(i - A_[i] - 0.5 + 1)
    a_max = int(i + A_[i] + 0.5)
    
    if(a_min < 0):
      a_min = 0
    
    if(a_max > N - 1):
      a_max = N -1 
      
    for j in range(a_min, a_max + 1):
      count[j] += 1

  A_ = count
  
print(A_)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(K):
        B = [0] * N
        for j in range(N):
            B[max(j-A[j],0)] += 1
            if j+A[j]+1 < N:
                B[j+A[j]+1] -= 1
            # print(j,B)
        A = list(accumulate(B[:]))
        if i > math.log2(N)+1:
            break
    print(*A)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(K):
        B = [0] * N
        for j in range(N):
            B[max(j-A[j],0)] += 1
            if j+A[j]+1 < N:
                B[j+A[j]+1] -= 1
            # print(j,B)
        A = list(accumulate(B[:]))
        if i >= math.log2(N):
            break
    print(*A)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

old_ai = ai
cnt = 0

aij = [[0 for i in range(n)] for j in range(2)]
aij[0] = ai

while 1 == 1:
    li = [0]*(n+1)
    for i in range(n):
        li[max(0,i-aij[0][i])] += 1
        li[min(n,i+1+aij[0][i])] -= 1
        #print(li)
    #print(li)
    tmp = 0
    for i in range(n):
        if i == 0:
            aij[1][i] = li[i]
            tmp += aij[1][i]
        else:
            aij[1][i] = li[i] + aij[1][i-1]
            tmp += aij[1][i]
    #print(rui)
    if aij[1] == aij[0]:
        print(*aij[1])
        exit()
        break
    cnt += 1
    if cnt == k:
        print(*aij[1])
        exit()
    aij[0] = aij[1]

Submission status: Wrong Answer

Solution code:
n,k=[int(_) for _ in input().split()]
A=[int(_) for _ in input().split()]
_A=[0 for i in range(n+1)]
for i in range(k):
    for j in range(n+1):
        _A[j]=0
    for j in range(n):
        _A[max(0,j-A[j])]+=1
        _A[min(n,j+A[j]+1)]-=1
    for j in range(1,n):
        _A[j]+=_A[j-1]
        
    for j in range(n):
        A[j]=_A[j]
    
    if sum(A)==n*n:
        break
print(i)
for i in range(n):
    print(A[i],end=" ")
print()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=30:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N-1):
      imos[i+1]+=min(N,imos[i])
      A[i]=min(N,imos[i])
    A[N-1]=min(N,imos[N-1])  
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

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

ML = 20
r = min(ML,k)

for l in range(r):
    imos = [0]*(n+1)
    for i in range(n):
        left = max(0,i-a[i])
        right = min(n,i+a[i]+1)
        
        imos[left] += 1
        imos[right] -= 1
        
    c = 0
    for i in range(n):
        c += imos[i]
        a[i] = c
        
print(*a)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=41:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N-1):
      imos[i+1]+=min(N,imos[i])
      A[i]=min(N,imos[i])
    A[N-1]=min(N,imos[N-1])  
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
import copy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n,k=MI()
lis=LI()
for i in range(min(k,100)):
    u=copy.deepcopy(lis)
    lis=[0 for i in range(n)]
    for i in range(n):
        lis[max(0,i-u[i])]+=1
        if i+u[i]+1<n:
            lis[i+u[i]+1]+=-1
    lis=list(accumulate(lis))
    #print(lis)
print(lis)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=40:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N-1):
      imos[i+1]+=min(N,imos[i])
      A[i]=min(N,imos[i])
    A[N-1]=min(N,imos[N-1])  
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

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


def proc():
    global A
    B = [0 for _ in range(N)]

    for i in range(0,N):
        f = i - A[i]
        t = i + A[i]
        for j in range(max(0, f), min(N, t)):
            B[j] += 1
    
    A = B

for _ in range(0, K):
    proc()

print(" ".join(map(lambda a: str(a), A)))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=40:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N-1):
      imos[i+1]+=imos[i]
      A[i]=min(N,imos[i])
    A[N-1]=min(N,imos[N-1])  
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
ANS=["N"]*N
if K>=50:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N-1):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    A[N-1]=imos[N-1]  
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,k = map(int,input().split())
l = [int(a) for a in input().split()]
for _ in range(max(k,50)):
    a = [0] * (N+1)
    for i,x in enumerate(l):
        a[max(0,i-x)] += 1
        a[min(i+x+1,N)] -= 1
    l = np.cumsum(np.array(a))[:-1].tolist()
print(' '.join(map(str, l)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

for i in range(k):
  x = np.zeros(n,int)

  for j in range(n):
    L=max(0,j-a[j])
    R=min(n-1,j+a[j]+1)
    x[L:R] += 1
  
  a += x

print(a)

Submission status: Wrong Answer

Solution code:
import math
from itertools import accumulate

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

printed_lst = []
for _ in range(K):
    s = [0]*N
    for i in range(N):
        left = i - al[i]
        right = i + al[i]
        if left < 0:
            left = 0
        s[left] += 1
        if right+1 <= N-1:
            s[right+1] -= 1
        #print(left,right)
    al = list(accumulate(s))
    #print(al)
    if al in printed_lst:
        print(' '.join([str(i) for i in al]))
        print('end')
        exit()
    else:
        printed_lst.append(al)

print(' '.join([str(i) for i in al]))

Submission status: Wrong Answer

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

data = [0]*(N)
l,r =0,0
v =1
ans = [0]*N


for j in range(K):
    if j !=0:
        A = ans
    data = [0]*(N)
    for i in range(N):
        l,r = i-A[i],i+A[i]
        if l >=0:
            data[l]+=v
        else:
            data[0]+=v
        if r+1 < N:
            data[r+1] -=v
            
    for i in range(1,N):
        ans[0] = data[0]
        ans[i] = ans[i-1]+data[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))+[0]
p=30

if K<=p:    
    for i in range(K):
        B=[0]+[0]*N+[0]
        for j in range(1,N+1):
            left  = max(0,j-A[j])
            right = min(N+1,j+A[j]+1)
            B[left]  += 1
            B[right] -= 1
        A[0]=B[0]
        for k in range(1,N+1):
            A[k]=A[k-1]+B[k]
else:
    A=[N]*(N+2)
print(*A[1:N+1])

Submission status: Wrong Answer

Solution code:
import math
def update(A,N):
    B=[0 for i in range(N+1)]

    for i in range(N):
        l = max(0,i-A[i])
        r = min(N,i+A[i]+1)
        B[l]+=1
        B[r]-=1
    A[0]=B[0]
    for i in range(1,N):
        B[i]+=B[i-1]
        A[i]=B[i]

def resolve():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(min(M,1+int(math.log2(N)))):
        update(A,N)
    print(" ".join(map(str,A)))
resolve()

Submission status: Wrong Answer

Solution code:
import math
def update(A,N):
    B=[0 for i in range(N+1)]

    for i in range(N):
        l = max(0,i-A[i])
        r = min(N,i+A[i]+1)
        B[l]+=1
        B[r]-=1
    A[0]=B[0]
    for i in range(1,N):
        B[i]+=B[i-1]
        A[i]=B[i]

def resolve():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(min(M,int(math.log2(N)))):
        update(A,N)
    print(" ".join(map(str,A)))
resolve()

Submission status: Wrong Answer

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

for _ in range(min(50, k)):
    l = [0]*(n+1)
    for i in range(n):
        l[max(i-a[i], 0)] += 1 #光の届く距離（後ろ）
        l[min(i+a[i]+1, n)] -= 1 #光が届かなくなる距離(前)
        print(l)
    add = 0
    for i in range(n):
        add += l[i] #光の届いている電球の数を累積
        a[i] = add
print(*a)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,k = map(int,input().split())
l = [int(a) for a in input().split()]
m = np.array([N] * N)
for _ in range(k):
    a = np.array([0] * N)
    for i,x in enumerate(l):
        if i <= x and  N-i-1 <= x:
            X = [1] * N
        elif i <= x:
            X = [1] * (i+1+x) + [0] * (N-i-x-1)
        elif N-i-1 <= x:
            X = [0] * (i-x) + [1] * (x+N-i)
        else:
            X = [0] * (i-x) + [1] * (2*x + 1) + [0] * (N-x-i-1)
        a += np.array(X)
    if (a == m).all():
        break
    else:
        l = a
print(a)

Submission status: Wrong Answer

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

def trans(arr):
    result=[]
    for i in range(1,len(arr)+1):
        ans=0
        for j in range(1,len(arr)+1):
            kyori=abs(i-j)
            if kyori<=arr[j-1]:
                ans+=1
            else:
                continue
        result.append(ans)
    arr=result
    return arr

for i in range(K):
    A=trans(A)

print(A)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
  
a=[0]*n
ans=[0]*n
a=list(map(int,input().split()))
check=math.ceil(math.log2(n))+1
if (k>=check):
  a=[n]*n
  print(" ".join(map(str,a)))
else:
  for _ in range(k):
    ans=[0]*n
    table=[0]*n
    for i in range(n):
      left=max(0,i-a[i])
      right=min(n-1,i+a[i])
      table[left]+=1
      if (right+1<n):
        table[right+1]-=1
      #print(left,right)
      #for j in range(left,right+1):
      #  ans[j]+=1
    #print(table)
    for i in range(1,n):
      table[i]+=table[i-1]
    a=table
 
  print(" ".join(map(str,a)))