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

Solution code:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
import numpy as np
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

def update(a):
    b = np.zeros((n, n))
    for i in range(n):
        b[i, max(0, i-int(a[i])):min(n, i+int(a[i])+1)] = 1
    return np.sum(b, axis=0)
end = np.full(n, n)

for i in range(k):
    if np.all(a == end):
        break
    a = update(a)
for i in range(n):
    print(str(int(a[i]))+" ",end = "" )

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
A_list = [0] + [int(e) for e in input().split()]

steady_state_A_list = [N for_ in range(N+1)]

#そのままやると10**5 **2　でTLE
#自分の座標を通過するまでは、自分の明るさ＝照射範囲は変わらない

#is_lighted[i][j]…iの座標のランプがjを照らすなら1否なら0の行列
#これで照らされる個数をカウントしていけばOK

edge = [[0 for _ in range(N+2)]]
center = [[0] + [0 for _ in range(1,N+1)] + [0] for i in range(N)]
is_lighted = edge + center + edge

def calc_lighted_area():
    for i in range(1,N+1):
        d = A_list[i]
        
        #照射範囲を求める
        if i-d < 0:
            left_side = 0
        else:
            left_side = i-d

        if i+d > N:
            right_side = N+1
        else:
            if d != 0:
                right_side = i+d+1
            else:
                right_side = left_side + 1
        
        is_lighted[i][left_side:right_side] = [1 for i in range(right_side - left_side)]

#for i in range(1,N+1):
#    print(is_lighted[i][1:N+1])

calc_lighted_area()

for j in range(K):
    for i in range(1,N+1):
        Bi = sum([row[i] for row in is_lighted])        
        A_list[i] = Bi
    calc_lighted_area()

    if A_list == steady_state_A_list:
        break

print(' '.join(map(str, A_list[1:N+1])))

Submission status: Runtime Error

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)

def operation():
  global A, B, N
  for i in range(1, N+1):
     left = math.ceil(i - A[i] - 0.5)
    right = math.floor(i + A[i] + 0.5)
    if left < 1:
      left = 1
    if right > N:
      right = N
    for j in range(left, right+1):
      B[j] += 1


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    A[i] = B[i]
    B[i] = 0
  operation()

print(A[1:])

Submission status: Runtime Error

Solution code:
import numpy as np

if __name__ == '__main__':
    N, K = map(int, input().strip().split(" "))
    A = np.array(input().strip().split(" ")).astype(int)

    if N <= K:
        print(" ".join([str(N)]*N))
    else:
        B = np.identity(N).astype(bool)
        for i in range(K):
            for j in range(N):
                for k in range(max(0, j - A[j]), min(j + A[j] + 1, N), 1):
                    B[j][k] += 1
            A = np.sum(B, axis=0)
        print(" ".join(A.astype(str)))

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
A_list = [0] + [int(e) for e in input().split()]

steady_state_A_list = [N for_ in range(N+1)]

#そのままやると10**5 **2　でTLE
#自分の座標を通過するまでは、自分の明るさ＝照射範囲は変わらない
0123
#is_lighted[i][j]…iの座標のランプがjを照らすなら1否なら0の行列
#これで照らされる個数をカウントしていけばOK

edge = [[0 for _ in range(N+2)]]
center = [[0] + [0 for _ in range(1,N+1)] + [0] for i in range(N)]
is_lighted = edge + center + edge

def calc_lighted_area():
    for i in range(1,N+1):
        d = A_list[i]
        
        #照射範囲を求める
        if i-d < 0:
            left_side = 0
        else:
            left_side = i-d

        if i+d > N:
            right_side = N+1
        else:
            if d != 0:
                right_side = i+d+1
            else:
                right_side = left_side + 1
        
        is_lighted[i][left_side:right_side] = [1 for i in range(right_side - left_side)]

#for i in range(1,N+1):
#    print(is_lighted[i][1:N+1])

calc_lighted_area()

for j in range(K):
    for i in range(1,N+1):
        Bi = sum([row[i] for row in is_lighted])        
        A_list[i] = Bi
    calc_lighted_area()

    if A_list == steady_state_A_list:
        break

print(' '.join(map(str, A_list[1:N+1])))

Submission status: Runtime Error

Solution code:
n,k,*a=map(int,open(0).read().split())
r=range(n)
while k:
 k-=1;b=[0]*n*2
 for i in r:t=a[i];b[max(0,i-t)]+=1;b[i-~t]-=1
 for i in r:b[i+1]+=b[i]
 if max(a:=b[:n])==n:break
print(*a)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
Ad = [0] * (N)

for _ in range(K):
    for Anum in range(N):
        A_count_low = Anum - A[Anum]
        A_count_high = (Anum + 1) + A[Anum]

        if A_count_low < 0:
            A_count_low = 0
        elif A_count_high > N:
            A_count_high = N

        if A_count_low == A_count_high:
            Ad[A_count_high - 1] = Ad[A_count_high - 1] + 1
        else:
            for Adnum in range(A_count_low, A_count_high):
                Ad[Adnum] = Ad[Adnum] + 1

    A = Ad
    Ad = [0] * (N)

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

Submission status: Runtime Error

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

for i in range(N*K):
  for i in range (N-1-S):
    c=S+1
    f=S-1
    if (A[c]>=c):
      B=B+1
    c=c+1
  for i in range(S):
    if(A[f]>=f):
      B=B+1
    f=f-1
  A[S]=B
  S=S+1
print(A)

Submission status: Runtime Error

Solution code:
import

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
        a = copy.copy(b)
        k -= 1
for i in range(n):
  print(b[i], ',', end = '')

Submission status: Runtime Error

Solution code:
def main():
	N, K = map(int,input().split())
	Light = list(map(int,input().split()))
 
	for i in range(K):
    	Count = [0 for j in range(N)]
    
    	for k in range(1,N+1):
        	for l in range(max(1,k-Light[k-1]),min(N+1,k+Light[k-1]+1)):
            	Count[l-1] += 1
            
    	Light = Count
 
	print(" ".join(map(str,Light)))
  
if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
import math
import numpy as np

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

eikyo = np.zeros((N,N))

def make_eikyo(A):
    for i,a in enumerate(A):
        satan = max(0,math.ceil(i-a))
        utan = min(N,math.floor(i+a))
        eikyo[i][:] = 0
        if satan==utan:
            eikyo[i][i] = 1
        else:
            eikyo[i][satan:utan+1] = 1
    n_A = eikyo.sum(axis=0)
    # print(eikyo)
    return n_A



for _ in range(K):
    A = make_eikyo(A)

for i,a in enumerate(A):
    if i+1 == A.size:
        print(int(a))
    else:
        print(int(a), end=' ')

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import math


class RAQ():
    
    def __init__(self, size):
        """初期化"""
        self.size = size
        n = 2 ** ((size-1).bit_length())
        treesize = n * 2
        st = [0] * treesize
        self.st = st
        self.offset = len(st) // 2

    @classmethod
    def from_array(cls, a):
        st = cls(len(a))
        for i, x in enumerate(a):
            st.add(i, i+1, x)
        return st

    def _add_topdown(self, a, b, value, k=1, l=0, r=-1):
        """区間[a, b) に対する加算
        k: 着目しているノード (1-indexed)
        l: 探索区間 st[l, r) の左端 (0-indexed)
        r: 探索区間 st[l, r) の右端 (0-indexed)
        """
        if r == -1:
            r = self.offset
        if r <= a or b <= l:
            return
        if l == r - 1:
            self.st[k] += value
            return
        if a <= l and r <= b:
            self.st[k] += value
            return
        mid = (l + r) // 2
        self._add(a, b, value, k * 2, l, mid)
        self._add(a, b, value, k * 2 + 1, mid, r)

    def _add_bottomup(self, a, b, value):
        """区間[a, b) に対する加算
        """
        a += self.offset
        b += self.offset - 1
        while a < b:
            if a & 1:
                self.st[a] += value
                a += 1
            a >>= 1
            if not b & 1:
                self.st[b] += value
                b -= 1
            b >>= 1
        if a == b:
            self.st[a] += value

    def add(self, a, b, value):
        """区間[a, b) に対する加算"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        return self._add_bottomup(a, b, value)

    def get(self, key):
        """値の取得"""
        offset = len(self.st) // 2
        k = offset + key
        v = self.st[k]
        k >>= 1
        while k > 0:
            v += self.st[k]
            k >>= 1
        return v


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    KL = 2 * math.log2(N) + 1
    if K > KL:
        print(' '.join([str(N)] * N))
        return
    raq = RAQ.from_array(A)
    a = [0 for i in range(N)]

    for k in range(KL):
        for i in range(N):
            a[i] = raq.get(i)
        for i in range(N):
            raq.add(i, i+1, -a[i])
            l = max(0, i-a[i])
            r = min(N, i+1+a[i])
            raq.add(l, r, 1)
    print(' '.join([str(raq.get(i)) for i in range(N)]))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
width = [0 for _ in range(N)]
A = np.array(A)
width = np.array(width)
for k in range(K):
    cnt = 0
    for i in range(N):
        if i-A[i]-0.5 < 0:
            left = int(i-A[i]-0.5)
        else:
            left = int(i-A[i]-0.5) + 1
        right = int(i+A[i]+0.5)
        if left < 0:
            left = 0
        if right > N-1:
            right = N - 1
        if left == 0 and right == len(A)-1:
            cnt += 1
        width[left:right+1] = np.vectorize(lambda x: x+1)(width[left:right+1])
    A = np.copy(width)
    if cnt == N:
        break
    width = np.zeros(N)

for i in range(N-1):
    print(int(A[i]), end=" ")
print(int(A[N-1]))

Submission status: Runtime Error

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

for k in range(K):
    B=[0]*N
    for i in range(N):
        p=i-A[i]
        q=i+A[i]
        if i-A[i]<=0:
            p=0
        elif i+A[i]>=N:
            q=N-1
        for j in range(p,q+1):
            B[j] += 1
        #print(p,q,A[i],i-A[i],i+A[i],A,B)
    A=copy.copy(B)
print(*A)

Submission status: Runtime Error

Solution code:
# 鬼がA1秒あたりV、子はB1秒あたりW T秒以内
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())

oni = a + v * t
ko = b + w * t

def a():
    if v == w:
        print("NO")
        return
    if ko <= oni:
        print("YES")
    else:
        print("NO")
a()

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(K):
    B = []
    for j in range(N):
        b = 0
        for k in range(N):
            c = abs(k - j)
            if A[k] >= c:
                b = b + 1
        B.append(b)
     A = B
print(A)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
if N / 2 + 1 < K:
    K = N / 2 + 1
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 A_list[i] == N:
            A_New_list[i] = N
            continue
        for j in range(A_list[i] + 1):
            if j == 0:
                A_New_list[i] += 1
            else:
                if i + j < N:
                    A_New_list[i+j] += 1
                if i - j >= 0:
                    A_New_list[i-j] += 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: Runtime Error

Solution code:

N,K=map(int,input().split())
A= list(map(int,input().split()))
new_A = A
len_A=len(A)
count_list = [0]*len_A
K_list=range(K)
A_list=range(len_A)
for i in K_list:
    for j in A_list:
        if(new_A[j]!=0):
            low_posi=j-new_A[j]
            if(low_posi<0):
                low_posi=0
            high_posi = j+new_A[j]
            if(high_posi>len_A):
                high_posi=len_A+1
            for k in range(low_posi,high_posi):
                count_list[k] += 1
        else:
            count_list[j]+=1
    new_A=count_list
    count_list = [0]*len_A
for s in new_A:
    print(str(s)+" ", end ="")
print("")

Submission status: Runtime Error

Solution code:
def main():
	N, K = map(int,input().split())
	Light = list(map(int,input().split()))
 
	for i in range(K):
    	Count = [0 for j in range(N)]
    
    	for k in range(1,N+1):
        	for l in range(max(1,k-Light[k-1]),min(N+1,k+Light[k-1]+1)):
            	Count[l-1] += 1
            
    	Light = Count
 
	print(" ".join(map(str,Light)))
  
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
import

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
        a = copy.copy(b)
        k -= 1
for i in range(n):
  print(b[i], ',', end = '')

Submission status: Runtime Error

Solution code:
n, K = map(int, input().split())
a = list(map(int, input().split()))
nexta = [0] * 5
for i in range(K):
  for j in range(len(a)):
    range_min = min(len(a), max(1, (j+1)-a[j]))
    range_max = max(1, min(len(a), (j+1)+a[j]))

    for k in range(range_min-1, range_max):
      nexta[k] += 1

  for l in range(len(a)):
    a[l] = nexta[l]

  if i != (K-1):
    nexta = [0] * 5

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

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = np.array(list(map(int, (input().split()))))
nd = np.zeros((N,N), dtype=bool)
# print(*A)
for i in range(min(K,N)):
    for j in range(N):
        nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
    # print(nd)
    A = np.count_nonzero(nd, axis=0)
    # print(*A)

print(*A)

Submission status: Runtime Error

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
        a = copy.copy(b)
        k -= 1
for i in range(n):
  print(b[i], ',', end = '')

Submission status: Runtime Error

Solution code:
import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    A = list(map(int,sys.stdin.readline().split()))
    if k >= n:
        ans = [n] * n
        print(' '.join([str(number) for number in ans]))
        return 0
    for _ in range(k): #k回操作
        next_A = [0] * n
        #print('操作')
        for x in range(n): #xは今考える座標
            #A[x]について考える
            if x - A[x] < 0:
                start = 0
            else: start = x - A[x]
            if x + A[x] > n:
                end = n - 1
            else: end = x + A[x]
            #print(start, end)
            for i in range(start, end + 1):
                next_A[i] += 1
        A = next_A
    print(' '.join([str(number) for number in A]))

    return 0

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
if N==1:
    print(1)
    exit()
if K >= N-1:
    for i in range(N-1):
        print(N,end=" ")
    print(N)
    exit()

for k in range(K):
    nextgen = [0]*N
    for i in range(N):
        # print("i=",i)
        a = A[i]
        start = i-a
        if i-a <0:
            start = 0
        end = i+a+1
        if i+a+1 <=N-1:
            nextgen[end] += -1
            end = N-1
        # print(start,end)
        nextgen[start] += 1
        # print(nextgen)
    dp = 0
    for i in range(N):
        dp += nextgen[i]
        A[i] = dp
    if A == [N]*(N):
        break
s = ' '.join([str(i) for i in A])
print(s)

Submission status: Runtime Error

Solution code:
n, k = map(input().split())
A = list(map(input().split()))
na = []

for i in range(k):
    na = 0
    for ln in range(n):
        na = na[n - A[n]:n+ A[n]+1] + 1
    A = A + na

Submission status: Runtime Error

Solution code:
if N==1:
    print(1)
    exit()
if K >= N-1:
    for i in range(N-1):
        print(N,end=" ")
    print(N)
    exit()

for k in range(K):
    nextgen = [0]*N
    for i in range(N):
        print("i=",i)
        a = A[i]
        start = i-a
        if i-a <0:
            start = 0
        end = i+a+1
        if i+a+1 <=N-1:
            nextgen[end] += -1
            end = N-1
        # print(start,end)
        nextgen[start] += 1
        # print(nextgen)
    dp = 0
    for i in range(N):
        dp += nextgen[i]
        A[i] = dp
    if A == [N]*(N):
        break
s = ' '.join([str(i) for i in A])
print(s)

Submission status: Runtime Error

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

import numpy as np
D = np.diag([1]*N)

is_all_on = [False] * N

for k in range(K):
    for i in range(N):
        if not is_all_on[i]:
            L = max(0, i-A[i])
            R = min(i+A[i]+1, N)

            D[i][L:R] = 1

            is_all_on[i] = D[i].all()

    A = D.sum(axis=0)
    
print(*D.sum(axis=0))

Submission status: Runtime Error

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


while k > 0:
  b = [0 for i in range(n)]
  for i in range(n):
    for j in range(n):
      if j - a[j] - 0.5 < i and i < j + a[j] + 0.5:
        b[i] += 1
        a = copy.copy(b)
        k -= 1
for i in range(n):
  print(b[i], ',', end = '')

Submission status: Runtime Error

Solution code:
5 2
1 0 0 1 0

Submission status: Runtime Error

Solution code:
N,K,*A = map(int, open(0).read().split())  
                                           
def left(i, d):                            
    if i < 0:                              
        return 0                           
    if i >= N:                             
        return 0                           
    v = A[i] - d + 0.5                     
    if v <= 0:                             
        return 0                           
    else:                                  
        return 1 + left(i - 1, d + 1)      
                                           
def right(i, d):                           
    if i < 0:                              
        return 0                           
    if i >= N:                             
        return 0                           
    v = A[i] - d + 0.5                     
    if v <= 0:                             
        return 0                           
    else:                                  
        return 1 + right(i + 1, d + 1)     
                                           
for _ in range(K):                         
    X = [0 for _ in range(N)]              
    for i, d in enumerate(A):              
        l = left(i-1, 1)                   
        r = right(i+1, 1)                  
        c = 1 + l + r                      
        X[i] = c                           
    A = X                                  
                                           
print(A)

Submission status: Runtime Error

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

Ad = [0] * (N)


for _ in range(K):
    for Anum in range(N):
        A_count_low = Anum - A[Anum]
        A_count_high = (Anum + 1) + A[Anum]

        if A_count_low < 0:
            A_count_low = 0
        elif A_count_high > N:
            A_count_high = N

        if A_count_low == A_count_high:
            Ad[A_count_high - 1] = Ad[A_count_high - 1] + 1
        else:
            for Adnum in range(A_count_low, A_count_high):
                Ad[Adnum] = Ad[Adnum] + 1
    else:
        A = Ad
        Ad = [0] * (N)

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

Submission status: Runtime Error

Solution code:
n,k=LI()
a=LI()

print(*[n]*n)

Submission status: Runtime Error

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

for i in range(K):
    # j番目の電球を操作
    B = [0] * N
    for j in range(N):
        maxA = int(j + A[j] + 0.5)
        minA = math.ceil(j - A[j] - 0.5)

        for k in range(max(0, minA), min(N + 1, maxA + 1)):
            B[k] += 1
    A = copy.copy(B)

for i in range(N):
    if i != (N - 1):
        print(A[i], end=" ")
    else:
        print(A[i])

Submission status: Runtime Error

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

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


for k in range(K):
    counterlist = [0]*N
    for i in range(N):
        d = A[i]
        u = max(0,i-d)
        v = min(N-1,i+d)
        counterlist[u:v+1]+=1
    if all(A==counterlist):
        print(*A)
        print("OH")
        break
    A = counterlist
    
        

else:
    print(*A)

Submission status: Runtime Error

Solution code:
num_bulb, count = map(lambda x: int(x), input().split())
brightness = list(map(lambda x: int(x), input().split()))

for i in range(count):
    next_brightness = [0] * num_bulb
    # それぞれの電球について
    for j in range(num_bulb):
      for lighted_i in range(max(0, j - brightness[j]), min(num_bulb+1, j + brightness[j] + 1)):
            next_brightness[lighted_i] += 1
    brightness = next_brightness

print(' '.join(list(map(lambda x: str(x), next_brightness))))

Submission status: Runtime Error

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

import numpy as np
D = np.diag([1]*N)

is_all_on = [False] * N

for k in range(K):
    if D.all():
        break
        
    else:
        
        for i in range(N):
            if not is_all_on[i]:
                L = max(0, i-A[i])
                R = min(i+A[i]+1, N)

                D[i][L:R] = 1
                
                is_all_on[i] = D[i].all()

        A = D.sum(axis=0)
    
print(*D.sum(axis=0))

Submission status: Runtime Error

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

for n in range(K):
  B=[0]*N
  for i in range(N):
    key=i-A[i]
    Key=i+A[i]+1
    if key<0:
      key=0
    if Key>N+1:
      Key=N
    for x in range(key,Key):
      B[x]+=1
  A=list(B)
B=[str(b) for b in B]
print(' '.join(B))

Submission status: Runtime Error

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

for i in range(N*K):
  for i in range (N-1-S):
    c=S+1
    f=S-1
    if (A[c]>=c):
      B=B+1
    c=c+1
  for i in range(S)
    if(A[f]>=f):
      B=B+1
    f=f-1
  A[S]=B
  S=S+1
print(A)

Submission status: Runtime Error

Solution code:
n, K = map(int, input().split())
a = list(map(int, input().split()))
nexta = [0] * 5
for i in range(K):
  for j in range(len(a)):
    range_min = min(len(a), max(1, (j+1)-a[j]))
    range_max = max(1, min(len(a), (j+1)+a[j]))
    for k in range(range_min-1, range_max):
      nexta[k] += 1

  for l in range(len(a)):
    a[l] = nexta[l]

  if i != (K-1):
    nexta = [0] * 5

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import math


class RAQ():
    
    def __init__(self, size):
        """初期化"""
        self.size = size
        n = 2 ** ((size-1).bit_length())
        treesize = n * 2
        st = [0] * treesize
        self.st = st
        self.offset = len(st) // 2

    @classmethod
    def from_array(cls, a):
        st = cls(len(a))
        for i, x in enumerate(a):
            st.add(i, i+1, x)
        return st

    def _add_topdown(self, a, b, value, k=1, l=0, r=-1):
        """区間[a, b) に対する加算
        k: 着目しているノード (1-indexed)
        l: 探索区間 st[l, r) の左端 (0-indexed)
        r: 探索区間 st[l, r) の右端 (0-indexed)
        """
        if r == -1:
            r = self.offset
        if r <= a or b <= l:
            return
        if l == r - 1:
            self.st[k] += value
            return
        if a <= l and r <= b:
            self.st[k] += value
            return
        mid = (l + r) // 2
        self._add(a, b, value, k * 2, l, mid)
        self._add(a, b, value, k * 2 + 1, mid, r)

    def _add_bottomup(self, a, b, value):
        """区間[a, b) に対する加算
        """
        a += self.offset
        b += self.offset - 1
        while a < b:
            if a & 1:
                self.st[a] += value
                a += 1
            a >>= 1
            if not b & 1:
                self.st[b] += value
                b -= 1
            b >>= 1
        if a == b:
            self.st[a] += value

    def add(self, a, b, value):
        """区間[a, b) に対する加算"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        return self._add_bottomup(a, b, value)

    def get(self, key):
        """値の取得"""
        offset = len(self.st) // 2
        k = offset + key
        v = self.st[k]
        k >>= 1
        while k > 0:
            v += self.st[k]
            k >>= 1
        return v


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    if K > math.log2(N):
        print(' '.join([str(N)] * n))
        return
    raq = RAQ.from_array(A)
    a = [0 for i in range(N)]
    for k in range(K):
        for i in range(N):
            a[i] = raq.get(i)
        for i in range(N):
            raq.add(i, i+1, -a[i])
            l = max(0, i-a[i])
            r = min(N, i+1+a[i])
            raq.add(l, r, 1)
    print(' '.join([str(raq.get(i)) for i in range(N)]))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Runtime Error

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

init = lamps
for i in range(K):
    act = np.zeros((N, N))
    for i in range(N):
        if init[i] == 0:
            print("skip")
            continue
        d = math.floor(init[i] + 0.5)
        dmin = i - d
        dmax = i + d
        if dmin < 0:
            dmin = 0
        if dmax > N-1:
            dmax = N-1
        act[i][dmin:dmax+1] = 1
        act[i][i] = 0
    s = np.sum(act, axis=0)
    init = s + np.ones(N)
print(init)

Submission status: Runtime Error

Solution code:
n, k = [int(e) for e in input().split()]
lista = [int(e) for e in input().split()]

import numpy as np

dp = np.array(lista,dtype='int64')

for j in range(k):
    ans = np.zeros(n*n,dtype='int64').reshape((n,n))
    for i in range(n):
        ans[i][max(0,int(i-dp[i])):i] +=1
        ans[i][i:i+int(dp[i])+1] +=1
    dp=ans.sum(axis=0)

print(str(dp)[1:-1])

Submission status: Runtime Error

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])
 
A_ = list(map(int, input().split()))
 
for i in range(K):
  ltd = [1 for i in range(N)]
  for j in range(N):
    rng = A_[j]
    for d in range(1, rng+1):
      if j - d >= 0:
        ltd[j - d] += 1
      if j + d < N:
        ltd[j + d] += 1
  A_ = ltd
 
ans = ' '.join(A_)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n, k= map(int, input().split())
a = list(map(int, input().split()))
ans = [0]*n

for c in range (n):
    if(a[c] > 0):
        s1= c-a[c]-0.5
        s2=c+a[c]+0.5
        s1,s2= int(s1), int(s2)
        if(s1==0):
            s1=0
        for cs in range (s1 , (s2+1)):
            ans[cs] = ans[cs]+1

for c in range (n):
    print(ans[c] ,end=" ")

Submission status: Runtime Error

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

for i in range(K):
    Count = [0 for j in range(N)]
    
    for k in range(1,N+1):
        for l in range(k-Light[k-1],k+Light[k-1]+1):
            Count[l-1] += 1
            
    Light = Count

print(" ".join(map(str,Light)))

Submission status: Runtime Error

Solution code:
[N,K]=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
if sum(A)==0:print(A)
elif K>N:print(' '.join([N for i in range(N)]))

Submission status: Runtime Error

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

for n in range(K):
  B=[0]*N
  for i in range(N):
    key=i-A[i]
    Key=i+A[i]+1
    if key<0:
      key=0
    if Key>N+1:
      Key=N
    for x in range(key,Key):
      B[x]+=1
  A=list(B)
print(B)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
if N + 2 < K * 2:
    K /= 2
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):
        for j in range(A_list[i] + 1):
            if j == 0:
                A_New_list[i] += 1
            else:
                if i + j < N:
                    A_New_list[i+j] += 1
                if i - j >= 0:
                    A_New_list[i-j] += 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: Runtime Error

Solution code:
num_bulb, count = map(lambda x: int(x), input().split())
brightness = list(map(lambda x: int(x), input().split()))

for i in range(count):
    next_brightness = [0] * num_bulb
    # それぞれの電球について
    for j in range(num_bulb):
      for lighted_i in range(j - brightness[j], j + brightness[j] + 1):
            next_brightness[lighted_i] += 1
    brightness = next_brightness

print(' '.join(list(map(lambda x: str(x), next_brightness))))