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 collections import defaultdict

n,k=map(int,input().split())
l=list(map(int,input().split()))
x=1
for i in range(k):
	if(x>n):
		break
    if(x==1):
        x=x*3
	
    else:
	
        x=x*2;
	d=defaultdict(lambda:1)
	for j in range(n):
		
		for k in range(1,l[j]+1):
			if(j+k==n):
				break
			
			d[j+k]+=1
		for k in range(1,l[j]+1):
			if(j-k==-1):
				break
			d[j-k]+=1
		
	
	for j in range(n):
		l[j]=d[j]
for i in l:
	print(i,end=" ")

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(" ".join(map(str, A)))

Submission status: Runtime Error

Solution code:
def get_lump(target_list, num):
    result_list = [0] * num
    flg = False
    for target in target_list:
        if target < num:
            flg = True
            break

    if flg == True:
        for target_num in range(len(target_list)):
            min_range = target_num - target_list[target_num] - 0.5
            max_range = target_num + target_list[target_num] + 0.5
            for result_num in range(len(result_list)):
                if min_range < result_num < max_range:
                    result_list[result_num] += 1
        return result_list


def main():
    total = list(map(int, input().split()))
    akarusa = list(map(int, input().split()))

    for i in range(total[1]):
        akarusa = get_lump(akarusa, total[0])

    kaitou = ''
    for j in range(len(akarusa)):
        if kaitou == '':
            kaitou = str(akarusa[j])
        else:
            kaitou = kaitou + ' ' + str(akarusa[j])

    print(kaitou)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np


def nextL(A, D):
    L = D
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        L[i-1][n+i-a:n+i+a+1] = line
        i+=1
    L = L[:][n+1:2*n+1]
    Na = np.sum(L, axis=0)
    return Na


n, k = map(int, input().split())
A = [int(a) for a in input().split()]

D = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Na = nextL(A, D)
        A = Na
    Li=[str(a) for a in A]
    Li=" ".join(Li)
    print(Li)

Submission status: Runtime Error

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


dp = [0]*n
for i in range(k):
    for j in range(n):
        dp[j]+=1
        for x in range(a[j]):
            if not j+1+x>=n: dp[j+1+x]+=1
            if not j-1-x<0: dp[j-1-x]+=1
        a+=dp
print("".join(dp))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = input().split()
AK = [[0 for j in range(N)] for i in range(2)]
for l in range(N):
  AK[0][l] = int(AK[0][l]) + int(A[l])

for m in range(1,K+1,1):
  for o in range(N):
    for x in range(N):
      if AK[0][o]==N:
        AK[1] = Ak[1] + 1
      else:
        if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)):
          AK[1][x] = AK[1][x] +1
  AK[0] = AK[1]
  AK[1] = [0] * N
print(*AK[0])

Submission status: Runtime Error

Solution code:
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    dict = {}
    temp = {}
    for i in range(N):
        dict[i+1] = A[i]
        temp[i+1] = 0

    for j in range(K):
        for m in range(1,N+1):
            if dict[m] < N:
                break
            else:
                if m == N:
                    ans = list(dict.values())
                    ans2 = str(ans[0])
                    for i in range(1,N):
                        ans2 += (' ' + str(ans[i]))
                    return(ans2)
                continue

        for h in range(1,N+1):
            if dict[h]==N and dict[h-1]==N and dict[h+1]==N and h+1 < N+1:
                break
            temp2 = dict[h]
            for n in range(h-temp2,h+temp2+1):
                if n <= 0:
                    continue
                elif n > N:
                    break
                else:
                    temp[n] += 1

        for i in range(1,N+1):
            dict[i] = temp[i]
            temp[i] = 0

    ans = list(dict.values())
    ans2 = str(ans[0])
    for i in range(1,N):
        ans2 += (' ' + str(ans[i]))
    return(ans2)

print(main())

Submission status: Runtime Error

Solution code:
import math
n,k = map(int,input().split())
a = input()
a = [float(s) for s in a]

for i in range(k):
    for j in range(n):
        hani = j+1 + a[j+1] + 0.5
        hani = math.floor(hani)
        a[range(hani)] =a[range(hani)] + 1
        
print(a)

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:
            continue
        d = math.floor(init[i] + 0.5)
        dmin = i - init[i]
        dmax = i + init[i]
        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)
result = init.astype("int64")
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np


def nextL(A, D):
    L = D
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        L[i-1, n+i-a:n+i+a+1] = line
        i+=1
    L = L[:, n+1:2*n+1]
    Na = np.sum(L, axis=0)
    return Na


n, k = map(int, input().split())
A = [int(a) for a in input().split()]

D = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Na = nextL(A, D)
        A = Na
    Li=[str(a) for a in A]
    Li=" ".join(Li)
    print(Li)

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(o_A):
    for i,a in enumerate(o_A):
        satan = max(0,math.ceil(i-a-0.5))
        utan = min(N,math.floor(i+a+0.5))
        eikyo[i,:] = 0
        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).copy()
    # print(A)
    if np.all(A>=N):
        break
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 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:
            continue
        # d = math.floor(init[i] + 0.5)
        dmin = i - init[i]
        dmax = i + init[i]
        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)
result = init.astype("int64")
ans = list(map(str,result.tolist()))
print(" ".join(ans))

Submission status: Runtime Error

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

for i in range(0, K):
  print(b = 2 * A[i] + 1, end = ' ')

Submission status: Runtime Error

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

count = 0
for l in len(a):
        b = memo.append(0)
        
while count <= k:
    count += 1
    for i, d in enumerate(a):
        num += 1
        sec1 = x - d - 1
        sec2 = x + d
        for j in b[sec1, sec]:
            j += 1
print(b)

Submission status: Runtime Error

Solution code:

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

for i in range(k):
  for j in range(n):
	for k in range(x-d-0.5,x+d+0.5):
      if(a[k]):
        a[k] += 1
print(a)

Submission status: Runtime Error

Solution code:
from collections import deque
import collections
import itertools

N,K=map(int,input().split())
A=list(map(int,input().split()))
d=deque()
for i in range(1,K+1):
    count=0
    if count==0:
        for i in A:
            count+=1
            M=count+i
            m=count-i
            if M>N:
                M=N
            if m<1:
                m=1
            l=list(range(m,M+1))
            d.append(l)
    else:
          for i in d:
            count+=1
            M=count+i
            m=count-i
            if M>N:
                M=N
            if m<1:
                m=1
            l=list(range(m,M+1))
            d.append(l)
    dd=list(itertools.chain.from_iterable(d))
    c=collections.Counter(dd)
    d=deque(c.values())
d=map(str,list(d))
d=" ".join(d)
print(d)

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()
a = np.array(a)
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())
list_a = list(map(int,input().split()))
z = []
if k == 1:
	for i in range(1,n):
    	for s in range(0,n):
        	if list_a[s] >= abs(i-(s+1)):
            	list_a[i-1] += 1
    for x in list_a:
  		print(x,end=" ")
else:
    for i in range(1,n):
    	for s in range(0,n):
      		if list_a[s] >= abs(i-(s+1)):
                list_a[i-1] += 1
  	for _ in range(k-1):
      	for i in range(1,n):
            list_a[i] = 0
            for s in range(0,n):
				if list_a[s] >= abs(i-(s+1)):
                	list_a[i-1] += 1
	for x in list_a:
  		print(x,end=" ")

Submission status: Runtime Error

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

for num in range(k):
    light = [0]
    ans = [0] * n
    for i,ramp in enumerate(li,1):
        a = max(i - ramp,1)
        b = min(i + ramp,n)
        light.append([a,b])

    for j, k in light:
        for l in range(j,k+1):
            ans[l-1] += 1
    li = ans.copy()

print(*ans,sep=" ")

Submission status: Runtime Error

Solution code:
import math
import sys

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):
    if A[i] != B[i]:
      A[i] = B[i]
    B[i] = 0
  operation()
  if A == B:
    ans = [N]* N
	print(ans)
    sys.exit()

print(A[1:])

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np


def nextLights(A, D):
    Lights = D
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A


n, k = map(int, input().split())
A = [int(a) for a in input().split()]

D = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Next_A = nextLights(A, D)
        A = Next_A
    L=[str(a) for a in A]
    L=" ".join(L)
    print(L)

Submission status: Runtime Error

Solution code:
import copy
N,K = map(int, input().split())
A = list(map(int,input().split()))
for i in range(K):
    B = copy.copy(A)
    A =[0]*N
    for j in range(N):
        if B[j] == 0:
            A[j] = A[j]+1
        elif B[j] > j:
            for k in range(0,j+B[j]+1):
                A[k] = A[k]+1
        elif B[j]+j > N-1:
            for k in range(j-B[j],N):
                A[k] = A[k]+1
        else:
            for k in range(j-B[j],j+B[j]+1):
                A[k]= A[k]+1
    
for s in range(N):
    print(A[s],end=" ")

Submission status: Runtime Error

Solution code:
import numpy as np

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

for i in range(0,k):
  npb=np.zeros(n, dtype=int)
  for j in range(0,n):
    js=j-npa[j]
    je=j+npa[j]
    if (js <=0): js=0
    if (je >=n-1): je=n-1
    npb[js:je+1]+=1

  npa=npb

print (*npa)

Submission status: Runtime Error

Solution code:
# n,k,*l = map(int,open(0).read().split())
import copy
import numpy as np
import sys
for i in range(k):
#     print(l)
    ll = np.array([0] * n)
#     print(ll)
    for j, e in enumerate(l):
#         print('je',j,e)
#         print('a',ll[max(0,j-e):min(n,j + e+1)] )
#         print(min(0,j-e),max(n,j + e+1) )
        ll[max(0,j-e):min(n,j + e+1)] += 1
#         print('ll',ll)
    l =copy.deepcopy(ll)
#     print(l)
    
    if np.all(l == n):
        print(' '.join([str(i) for i in l]))
        sys.exit()
print(' '.join([str(i) for i in l]))

Submission status: Runtime Error

Solution code:
NK = list(map(int, input().split()))
A = list(map(int, input().split()))
ans =[0]*NK[0]
for i in range(NK[1]):
    if i == 0:
        B = set(A)
        C = sorted(list(B),reverse=True)
        for j in C:
            indexes = [m for m, e in enumerate(A) if e == j]
            for k in indexes:
                for l in range(A[k]):
                    if k + l + 1 <= NK[0] - 1 : 
                        ans[k + l + 1] += 1
                    if k - l - 1 >= 0 :
                        ans[k - l - 1] += 1
        ans =list(map(lambda x: x + 1, ans)) 
    else:
        B = set(ans)
        C = sorted(list(B),reverse=True)
        for j in C:
            indexes = [m for m, e in enumerate(ans) if e == j]
            for k in indexes:
                for l in range(ans[k]):
                    if k + l + 1 <= NK[0]- 1 : 
                        ans[k + l + 1] += 1
                    if k - l - 1  >= 0 :
                        ans[k - l - 1] += 1
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
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()
a = np.ndarray(a)
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.fill(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())
Mylist = input().split()
Mylist = [int(s) for s in Mylist]

def ZeroOrMore(NUM):
    if NUM > 0:
        return NUM
    else:
        return 0

def change(changingList):
    ANSList = [0] * len(changingList)
    for i in range(len(changingList)):
        ANSList[i] = 0
        for j in range(len(changingList)):
            print(changingList)
            if changingList[j] > 0:
                if j-i > 0:
                    if i >= (j-changingList[j]-1):
                        ANSList[i] += 1
                        print("1o")
                    else:
                        print("1x")
                else:
                    if i <= (j+changingList[j]+1):
                        ANSList[i] += 1
                        print("2o")
                    else:
                        print("2x")
            else:
                print("3x")
        print(ANSList[i])
    return ANSList

for i in range(K):
    Mylist = change(Mylist)


print(Mylist)

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
A = list(map(int,input().split()))
B = [int(0) for d in range(n)]
for i in range(k):
    for j in range(n):
        if int(A[j]) >= 1:
            min = (j+1) - int(A[j])
            max = (j+1) + int(A[j]) 
            if min <= e or e <= max:
                B[i] = int(B[i]) + 1
        min = 0
        max = 0
    A[i] = int(B[i])
print(A)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
mi = [0]*n
ma = [0]*n
now = [0]*n
for j in range(n):
    l = int(j+1 - a[j] - 0.5)
    b = int(j+1 + a[j] + 0.5)
    if l < 0:
        l = 0
    mi[j] += l
    ma[j] += b
    
    for i in range(l, b):
        a[j] = now[j]
        now[i] += 1
    a[j] = now[j]
print(*now)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

N, K = list(map(int, input().strip().split()))
a = np.array(input().strip().split(), dtype=int)

@njit(cache=True)
def solve(a):
    def calc(a):
        b = np.array([0]*N)
        for i in range(N):
            left = int(max(0, i-A[i]))
            right = int(min(N-1, i+A[i]))
            b[left:right+1] +=1
        return b.copy()
    
    for _ in range(K):
        a = calc(a)
    return a
    
ans = calc(a, 1)
ans = [str(x) for x in ans]
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
A = list(map(int,input().split()))
B = [int(0) for d in range(n)]
for i in range(k):
    for j in range(n):
        if int(A[j]) >= 1:
            min = (j+1) - int(A[j])
            max = (j+1) + int(A[j]) 
            if min <= e or e <= max:
                B[i] = int(B[i]) + 1
        min = 0
        max = 0
    A[i] = int(B[i])

Submission status: Runtime Error

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

a_tmp = [0] * n
a_range = []*n
#print(a_tmp)

for i in range(k):
    for x in range(n):
        # まずは一つ目が照らしている電球を考える
        # 範囲は式通り
        left = math.ceil(x - a_array[x] - 0.5)
        if left < 0:
            left = 0
        right  = math.floor(x + a_array[x] + 0.5)
        if right > n - 1:
            right = n -1
        #a_tmp = [a_tmp[i]+1 if (i>=left and i<right+1) else a_tmp[i] for i in range(0, n)]
        
        a_tmp2 = [0] * n
        a_insert = [1] * (right+1 - left)
        #print(a_insert)
        
        #a_tmp2[left:right-1] = a_insert
        a_tmp2[left:right] = a_insert
        #print(a_tmp2)
        
        #a_tmp = [x + y for (x, y) in zip(a_tmp2,a_tmp)]
        a_tmp =map(operator.add, a_tmp,a_tmp2)

        #for j in range(left, right+1):
            #a_tmp[j] += 1
        
        #print(a_tmp)
    a_array = a_tmp
    a_tmp = [0]*n

ans = " ".join(map(str, a_array))
print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
tmp = [0] * N
count = 0
keys = [i for i in range(N)]
bulb_to_check = {key: 0 for key in keys}

for t in range(K):
    if not bulb_to_check:
        break
    for i in bulb_to_check:  # i番目の電球の明るさを決定する
        for j in range(N):  # 各電球jが、電球iを照らしているかを確認する
            if j - A[j] - 0.5 <= i <= j + A[j] + 0.5:
                count += 1
        tmp[i] = count
        if tmp[i] == N:
            del bulb_to_check[i]  # 最大値に達した電球を対象から除く
        count = 0
    for l in bulb_to_check:
        A[l] = tmp[l]

print(*A)

Submission status: Runtime Error

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

def add(o):
    return o + k - i - 1

for i in range(k):
  a_c = [0 for y in range(n)]
  for j in range(n):
    ax = a[j]*2+1
    st = -a[j]+j
    gt = a[j]+j
    if j-a[j] < 0:
      ax -= abs(j-a[j])
      st = 0
    elif j+a[j] >= n:
      gt = n-1
      ax -= j-a[j]
    l = [1]*ax
    a_c[st:gt+1] = [x + y for (x, y) in zip(a_c[st:gt+1], l)]
  a = a_c
  if min(a) >= n:
    a = list(map(add, a))
    break

print(*a)

Submission status: Runtime Error

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

def add(o):
    return o + k - i - 1

for i in range(k):
  a_c = [0 for y in range(n)]
  for j in range(n):
    ax = a[j]*2+1
    st = -a[j]+j
    gt = a[j]+j
    if j-a[j] < 0:
      ax -= abs(j-a[j])
      st = 0
    elif j+a[j] >= n:
      gt = j
      ax -= j-a[j]
    l = [1]*ax
    a_c[st:gt+1] = [x + y for (x, y) in zip(a_c[st:gt+1], l)]
  a = a_c
  if min(a) >= n:
    a = list(map(add, a))
    break

print(*a)

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-int(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:
import sys
input = sys.stdin.readline
import numpy as np


def nextLights(A, Denn):
    Lights = Denn
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A


n, k = map(int, input().split())
A = [int(a) for a in input().split()]

Denn = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        Next_A = nextLights(A, Denn)
        A = A
    L=[str(a) for a in A]
    L=" ".join(L)
    print(L)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

"""
def nextLights(A, Defl):
    Lights = Defl
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A
"""

n, k = map(int, input().split())
A = [int(a) for a in input().split()]

Defl = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        #Next_A = nextLights(A, Defl)
        A = A
    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 = [int(0) for d in range(n)]
for i in range(k):
    for j in range(n):
        if int(A[j]) >= 1:
            min = (j+1) - int(A[j])
            max = (j+1) + int(A[j]) 
            for e in range(n):
                if min <= e or e <= max:
                    int(B[e]) = int(B[e]) + 1
        min = 0
        max = 0

Submission status: Runtime Error

Solution code:
from collections import deque

n,k=map(int,input().split())
A=list(map(int,input().split()))
#A=[0]*n
for i in range(min(k,50)):
    P=[]
    M=[]
    cnt=0
    for a in range(n):
        if A[a]==n:
            cnt+=1
            continue
        P.append(a-A[a])
        M.append(a+A[a]+1)
    P.sort()
    M.sort()
    P=deque(P)
    M=deque(M)
    C=[]
    m=n+100
    for j in range(n):
        if P:
            while P[0]<=j:
                P.popleft()
                cnt+=1
                if not P:
                    break
        while M[0]<=j:
            M.popleft()
            cnt-=1
        C.append(cnt)
        m=min(cnt,m)
    A=C
    if m==n:
        break
print(*A)

Submission status: Runtime Error

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
#    N = 10
#    K = 1
#    A = [0]*10
#    A[0] = 1

    for i in range(K):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[i]+1<=N:
                dm[x + A[x] + 1]+=-1
#            print(dm)
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

light_range = lambda x,d:[math.ceil(x-d-0.5) if (x-d-0.5) >= 0 else 0,math.floor(x+d+0.5)]

def update_lights(a_):
    light_nums = [0] * n
    light_ranges = [light_range(x+1,d) for x,d in enumerate(a_)]
    for x_, light_range_ in enumerate(light_ranges):
        for r in range(light_range_[0],int(light_range_[1])+1):
            if (r>=1 and r <= len(light_nums)): light_nums[r-1] += 1 
    return light_nums

updated_a = a
for _ in range(k):
    _a = updated_a
    updated_a = update_lights(_a)
print(' '.join(updated_a))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, K: int, A: "List[int]"):
    M = np.zeros((N,N))
    a, b = np.indices((N,N))
    rc_mat = np.abs(a-b)

    A = np.array(A)
    for k in range(K):
        B = np.sum(rc_mat - A <= 0, axis=1)
        A = B
    print(*A)

    # for k in range(K):
    #     B = [0] * N
    #     for i in range(N):
    #         d = A[i]
    #         if d == 0:
    #             B[i] += 1
    #             continue

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

    #     print(*A, '||', *[a-1 for a in B])
    #     # A = [a-1 for a in B]
    #     A = B.copy()

        
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

for k in range(n[1]):
  ans = []
  for i in range(n[0]):
    ans.append(0)
  for i in range(n[0]):
    s1 = (i + 1) - a[i] - 0.5 # x - d - 0.5
    if 1 > s1:
      s1 = 1
    s2 = (i + 1) + a[i] + 0.5 # x + d + 0.5
    if n[0] < s2:
      s2 = n[0]
    s1 = math.ceil(s1)
    s2 = math.floor(s2) + 1
    for j in range(s1, s2):
      ans[j-1] += 1
  a = ans    

print(*a)

Submission status: Runtime Error

Solution code:
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    flag = 0
    for k in range(K):
        imos = [0]*(N + 1)
        if flag == N:
            print([N]*(N))
            return
        for i in range(N):
            imos[max(0,i  - A[i])] += 1
            imos[min(N + 1,i + 1 + A[i])] -= 1
        for j in range(N):
            imos[j+1] += imos[j]
        A = imos[:N].copy()
    print(*A,sep=" ")
    return 

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ() + [0]

    for _ in range(k):
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        print(nA)
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
tmp = [0] * N
count = 0
keys = [i for i in range(N)]
bulb_to_check = {key: 0 for key in keys}

for t in range(K):
    if not bulb_to_check:
        break
    for i in bulb_to_check:  # i番目の電球の明るさを決定する
        if A[i] == N:
            del bulb_to_check[i]  # 最大値に達した電球を対象から除く
        else:
            for j in range(N):  # 各電球jが、電球iを照らしているかを確認する
                if j - A[j] - 0.5 <= i <= j + A[j] + 0.5:
                    count += 1
            tmp[i] = count
        count = 0
    for l in range(N):
        A[l] = tmp[l]

print(*A)

Submission status: Runtime Error

Solution code:
A = list(map(int, input().split()))
# DP = [0]*N
# DP2 = [0]*N
DP = [0]*N
DP2 = [[0] *N for p in range(N)]
for _ in range(K):
    for i in range(N):
        for j in range(A[i],-A[i]-1,-1):
            if A[i] == 0:
                DP[i] += 1
            else:
                pass
            if i != i-j and i-j >= 0 and i-j < N and DP2[i-j][i] ==0:
                DP[i-j] += 1
                DP2[i-j][i] = 1

            else:
                pass
    #print(DP)
    for k in range(len(DP)):
        A[k] += DP[k]
    DP = [0]*N
    #print(DP2)
    #print(A)

print(A)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

def nextLights(A, Defl):
    Lights = Defl
    i = 1
    for a in A:
        line = np.ones(a*2+1, dtype = int)
        Lights[i-1, n+i-a:n+i+a+1] = line
        i+=1
    Lights = Lights[:, n+1:2*n+1]
    Next_A = np.sum(Lights, axis=0)
    return Next_A

n, k = map(int, input().split())
A = [int(a) for a in input().split()]

Defl = np.zeros((n, 3*n+2), dtype = int)

if k >= n+1:
    print((str(n)+" ")*n)
else:
    for i in range(k):
        #Next_A = nextLights(A, Defl)
        A = A
    print(" ".join(str(a) for a in A))