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

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if w >= v:
    print('NO')
    sys.exit()

min_a = -1 * v * t + a
max_a = v * t + a
min_b = -1 * w * t + b
max_b = w * t + b

if min_a <= min_b and max_b <= max_a:
    print('YES')
else:
    print('NO')

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 = max(1, (j+1)-a[j])
    range_max = 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:
N,K=map(int,input())
A=list(map(int,input().split()))
for h in range(K):
  for i in range(N):
    count=0
    for j in A:
      if -j-0.5<=0 and 0<=j+0.5:
        count+=1
  A[i]=count
print(*A)

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 print_all(n, v):
    print(' '.join([str(v)] * n))

def print_array(n, a):
    print(' '.join(map(str, a)))


def solve(N, K, A):
    if K > math.log2(N):
        print(' '.join([str(v)] * n))
        return
    raq = RAQ.from_array(A)
    for k in range(K):
        a = [raq.get(i) for i in range(N)]
        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())
array = list(map(int, input().split()))
array = np.array(array)
Array = np.array([0]*n)
print(array)
print(Array)
def plusone(n):
    return n + 1

for j in range(k):
    for i in range(n):
        ai = array[i]
        Array[max(i-ai, 0):min(i+ai+1,n+1)] += 1#map(plusone, Array[max(i-ai, 0):min(i+ai+1,n+1)])
        if j == k - 1:
            answer = Array
    array = Array
    Array = [0] * n

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

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()))

print(brightness)

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))))

Submission status: Runtime Error

Solution code:
import math
n , k = map(int, input().split())
a = list(map(int,input().split()))
a1=[0]*(n+1)
k = min(k,int(math.log2(n)*2.5))
for i in range(k):
    for j in range(n):
        st=j-a[j]
        gl=j+a[j]
        if st<0:
            st=0
        if gl>=n:
            gl=n-1
        a1[st]+=1
        a1[gl+1]-=1
    for k in range(1,n):
        a1[k]=a1[k-1]+a1[k]
    a=a1[:n]
    a1=[0]*n
print(' '.join([str(n) for n in a]))

Submission status: Runtime Error

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

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

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


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

for i in range(k):
    A = nextLights(A, Defl)
print(" ".join(str(a) for a in A))

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 = [0] * 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
    ltd[j] += 1
  A_ = ltd
 
ans = ' '.join(A_)
print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
b = [0 for i in range(N+2)]
if K > 70:
    ans = [N for i in range(N)]
    print(*ans)
else:
    for _ in range(K):
        for i in range(N+2):
            b[i] = 0
        for i in range(N):
            b[max(0, i+1-a[i])] += 1
            b[min(N+1, i+1+a[i]+1)] -= 1
        for i in range(1, N+1):
            b[i] += b[i-1]
            a[i-1] = b[i]
    print(*a)

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()))))
# print(A)
for i in range(K):
    nd = np.zeros((N,N), dtype=bool)
    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:
def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    max = [N]*N

    for k in range(K):
        illumi = [0] * N
        i = 0
        for i in range(N):
            l = A[i]
            for j in range(max(0, i - l), min(N, i + l + 1)):
                illumi[j] += 1

        A = [i for i in illumi]

        if (A == max):
            print(print(" ".join(map(str, A))))
            exit(0)

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,K=int(input())
A=list(map(int,input().split()))
for h in range(K):
  for i in range(N):
    count=0
    for j in A:
      if -j-0.5<=0 and 0<=j+0.5:
        count+=1
  A[i]=count
print(*A)

Submission status: Runtime Error

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

    max = [N]*N

    for k in range(K):
        illumi = [0] * N
        i = 0
        for i in range(N):
            l = A[i]
            for j in range(max(0, i - l), min(N, i + l + 1)):
                illumi[j] += 1

        A = [i for i in illumi]

        if (A == N):
            print(print(" ".join(map(str, A))))
            exit(0)

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
three_hold_list = [0] *(3*N)
ans = ans = [N] * N
if (1.8)**(K//2) >= N :
    print(*ans)
else:
    for i in range(K):
        Accum = [0] *(3*N)
        for j in range(N):
            Accum[N+j-A[j]] += 1
            Accum[N+j+A[j]+1] -= 1
        num = 0
        for l in range(3*N):
            num += Accum[l]
            three_hold_list[l] = num
        if three_hold_list[N:2*N] == ans:
            break
        else:
            A = three_hold_list[N:2*N]
    print(*three_hold_list[N:2*N])

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
A = list(map(int, input().split()))
endA = [N]*N
for i in range(K):
    if A == endA:
        pass
    else:
        newA = [0]*N
        for j in range(N):
            for k in range(2*A[j]+1):
                if 0<=j-A[j]+k and j-A[j]+k <N:
                    newA[j-A[j]+k] += 1
        A = newA
    print(A)

Submission status: Runtime Error

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

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

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


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

for i in range(k):
    A = nextLights(A, Defl)
print(" ".join(str(a) for a in A))

Submission status: Runtime Error

Solution code:
# coding: utf-8
import string
import numpy as np
import math

n = list(map(int,input().split()))
b = list(map(int,input().split()))

a = np.array(b)

for i in range(n[1]):
    b = np.zeros(n[0],dtype=int)
    for j in range(n[0]):
        min = j - a[j]
        if(min<0):
            min = 0
        max = j + a[j] + 1
        if(max>n[0]):
            max = n[0]
        b[min:max] += 1
    a = b

print(*a)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = input().split()#string
A = list(map(int, A))
B = [[0 for i in range(N)] for j in range(K)]
for i in range(K):
  for j in range(N):
    tmp_low = j - A[j] 
    tmp_high = j + A[j] 
    if tmp_low <= 0:
      tmp_low = 0
    if tmp_high >= N:
      tmp_high = N
    for k in range(tmp_low, tmp_high+1, 1):
        B[i][k] += 1 
print(' '.join(map(str, B[-1])))

Submission status: Runtime Error

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

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

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


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

for i in range(k):
    A = nextLights(A, Defl)
print(" ".join(str(a) for a in 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-dp[i])):i] +=1
        ans[i][i:i+int(dp[i])+1] +=1
    dp=ans.sum(axis=0)

print( str(dp)[1:n*2])

Submission status: Runtime Error

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

for k in range(K):
    counterlist = np.array([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
    A = counterlist
    if set(A)=1:
        print(A)
        break
        

else:
    print(*A)

Submission status: Runtime Error

Solution code:
N,K=int(input())
A=list(map(int,input().split()))
for h in range(K):
  for i in range(N):
    count=0
    for j in A:
      if -j-0.5<=0 and 0<=j+0.5:
        count+=1
  A[i]=count
print(' '.join(str(A)))

Submission status: Runtime Error

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

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

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


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+2:n+i+a+3] = line
        i+=1
    Lights = Lights[:, n+3:2*n+3]
    Next_A = np.sum(Lights, axis=0)
    return Next_A

for i in range(k):
    A = nextLights(A, Defl)
print(" ".join(str(a) for a in A))

Submission status: Runtime Error

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

bef = copy.copy(A)
aft = [0 for _ in range(n)]
aft_array = np.array(aft)

for k in range(K):
    for i in range(n):
        a = bef[i]
        aft_array[max(0, i-a):min(n-1, i+a)+1]+=1
    bef = aft_array.tolist()
    aft = [0 for _ in range(n)]
    aft_array = np.array(aft)
print(*bef)

Submission status: Runtime Error

Solution code:
import numpy as np

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

for k in range(K):
    lights = np.zeros((N, N))
    for i in range(N):
        lights[i, max(0, i-A[i]):min(N, i+1+A[i])] = 1
    B = np.sum(lights, axis=0)
    A = list(map(int, B))
print(A)

Submission status: Runtime Error

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    B = [[0] * n for _ in range(k+1)]
    B[0] = A

    flag = False
    for i in range(k):
        for j in range(n):
            for m in range(j-B[i][j], j+B[i][j]+1):
                if j - B[i][j] >= 0 and j + B[i][j]+1 <= n:
                    B[i+1][m] += 1
                    B[i+1][m] = min(B[i+1][m], n)
        if B[i][n-1] == n:
            print(B[i])
            flag = True
            break

    if flag = False
        print(B[k+1])
resolve()

Submission status: Runtime Error

Solution code:
import numpy as np
N,K=map(int,input().split())
A= np.array(list(map(int,input().split())))
new_A = A
len_A=len(A)
count_list = np.zeros(len_A, dtype = int)
for i in range(K):
    for j in range(len_A):
        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
            count_list[low_posi:high_posi+1] += 1
        else:
            count_list[j]+=1
    new_A=count_list
    count_list = np.zeros(len_A,dtype=int)
for s in new_A:
  print(str(s)+" ", end ="")
print("")

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import copy
input = sys.stdin.readline
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    lighted = np.array([0]*N)
    for i,a in enumerate(A):
        area = len(lighted[max(0,i-a):min(i+a,N-1)+1])
        lighted[max(0,i-a):min(i+a,N-1)+1] += np.array([1]*area)
    
    for _ in range(K-1):
        tmp = np.array([0]*N)
        for i,a in enumerate(lighted):
            area = len(tmp[max(0,i-a):min(i+a,N-1)+1])
            tmp[max(0,i-a):min(i+a,N-1)+1] += np.array([1]*area)
        lighted = copy.deepcopy(tmp)
        if lighted[0] == N:
            break
    print(lighted)
if __name__ == '__main__':
    main()

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)

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

                D[i][L:R] = 1

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

Submission status: Runtime Error

Solution code:
[n, k] = map(int, input().split(' '))
a_s = map(int, input().split(' '))
for k_idx in range(0, k):
  for a_idx in range(0, n-1):
    a = a_s[a_idx]
    if a = 0:
      continue
    t_s = a_idx - a
    t_s = t_s if t_s >= 0 else 0
    t_e = a_idx + a + 1
    t_e = t_e if t_e <= n else n
    a_s[t_s:t_e] += a
print(a_s)

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 = [0] * 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
    ltd[j] += 1
  A_ = ltd
 
ans =  ' '.join(A_)
print(ans)

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)

for j in range(k):
    ans = np.zeros(n*n).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(dp)

Submission status: Runtime Error

Solution code:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
import numpy
for k in range(K):
    B = [0 for i in A]
    for j in range(max(A)+1):
        for i in range(N):
            if A[i] > 0:
                if i+A[i] < N:
                    B[i+A[i]] += 1
                if i-A[i] >= 0:
                    B[i-A[i]] += 1
                A[i] -= 1
            if A[i] == 0:
                B[i] += 1
                A[i] -= 1
    A = [b for b in 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()))

c = [1]*n
for j in range(k):
    b = [0]*n
    for i in range(n):
        if i-a[i]>0:
            start = i-a[i]
        else:
            start = 0
        if i+a[i]>n:
            end = n
        else:
            end = i+a[i]+1
        if start == 0 and end == n:
            b += c
        else:
            for l in range(start,end):
                 b[l] += 1
    a = b


print(*a)

Submission status: Runtime Error

Solution code:
import numpy as np
N,K=map(int,input().split())
A= np.array(list(map(int,input().split())))
new_A = A
len_A=len(A)
count_list = np.zeros(len_A, dtype = int)
for i in range(K):
    for j in range(len_A):
        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
            count_list[low_posi:high_posi+1] += 1
        else:
            count_list[j]+=1
    new_A=count_list
    count_list = np.zeros(len_A)
for s in new_A:
  print(str(s)+" ", end ="")
print("")

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int,input().split())
A = list(map(int, input().split()))
for _ in range(K):
    result=np.array([0]*N)
    for i in range(N):
        if i-A[i] < 0:
            idx_st=0
        else:
            idx_st=i-A[i]

        if i+A[i] > N:
            idx_end=N
        else:
            idx_end=i+A[i]+1

        n = idx_end - idx_st
        result+=np.array([0]*idx_st+[1]*n+[0]*(N-idx_end))
    A=result.copy()
print(*result)

Submission status: Runtime Error

Solution code:
[n, k] = map(int, input().split(' '))
a_s = map(int, input().split(' '))
for k_idx in range(0, k):
  for a_idx in range(0, n):
    a = a_s[a_idx]
    if a = 0:
      continue
    t_s = a_idx - a
    t_s = t_s if t_s >= 0 else 0
    t_e = a_idx + a + 1
    t_e = t_e if t_e <= n else n
    a_s[t_s:t_e] += a
print(a_s)

Submission status: Runtime Error

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    sa = sum(a)
    for i in range(k):
        mov = [0]*n
        for i,ai in enumerate(a):
            if i-ai >= 0:
                mov[i-ai] += 1
            else:
                mov[0] += 1
            if i+ai+1 < n:
                mov[i+ai+1] -= 1
        na = a*1
        sna = sa
        a[0] = mov[0]
        sa = mov[0]
        for i in range(1,n):
            a[i] = a[i-1]+mov[i]
            sa += a[i]
        if sna == sa:
            break
    print(" ".join(map(str,a)))

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

n, k = map(int, input().strip().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)

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

for i in range(k):
    A = nextLights(A, Defl)
print(" ".join(str(a) for a in A))

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)

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

            D[i][L:R] = 1
            
    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()))
if n<=k:
    print(a*n)

Submission status: Runtime Error

Solution code:
from math import ceil

data_len, count = map(int, input().split())
data = list(map(int, input().split()))

def calc(data, data_len):
    result = [0] * data_len
    for i, d in enumerate(data):
        start = ceil(i - d - 0.5)
        end = int(i + d + 0.5)

        if start < 0:
            start = 0
        if data_len < end:
            end = data_len -1

#        print('itter: {}, start: {}, end :{}'.format(i, start, end))

        for j in range(start, end+1):
#             print(result)
            result[j] += 1
    return result

for _ in range(count):
    data = calc(data, data_len)

print(' '.join(list(map(str, data))))

Submission status: Runtime Error

Solution code:
N,K=int(input())
A=list(map(int,input().split()))
for h in range(K):
  for i in range(N):
    count=0
    for j in A:
      if -j-0.5<=0 and 0<=j+0.5:
        count+=1
        A[i]=count
print(' '.join(str(count)))

Submission status: Runtime Error

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


for _ in range(K):
    B = [0] * N
    for i in range(N):
        B[i] += 1
        if A[i] > 0:
            if (A[i] > N - 1):
                B = map(lambda x: x+1, B)
            else:
                for j in range(A[i]):
                    if (i - j - 1 >= 0):
                        B[i-j-1] += 1
                    if (i + j + 1 < N):
                        B[i+j+1] += 1
    A = B

for _ in B:
    print(_, end=' ')

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 = [0] * 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
      ltd[j] += 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()))
current = a[:]
for _ in range(k):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += stack % 10
        stack //= 10
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += stack % 10
        stack //= 10
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)

Submission status: Runtime Error

Solution code:
from math import floor, ceil

data_len, count = map(int, input().split())
data = map(int, input().split())

def calc(data, data_len):
    result = [0] * data_len
    for i, d in enumerate(data):
        start = ceil(i - d - 0.5)
        end = int(i + d + 0.5)

        if start < 0:
            start = 0
        if data_len < end:
            end = data_len -1

#        print('itter: {}, start: {}, end :{}'.format(i, start, end))

        for j in range(start, end+1):
#             print(result)
            result[j] += 1
    return result

for _ in range(count):
    data = calc(data, data_len)

print(' '.join(list(map(str, data))))

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 = [0] * N
  for j in range(N):
    rng = A_[j]
    for d in range(1, rng):
      if j - d >= 0:
        ltd[j - d] += 1
      if j + d < N:
      ltd[j + d] += 1
      ltd[j] += 1
  A_ = ltd

ans =  ' '.join(A_)
print(ans)

Submission status: Runtime Error

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


def light(As,N):
    A0 = np.zeros(N)
    for i in range(N):
        lp = As[i]
        lmin = max(0, i - lp)
        lmax = min(N - 1, i + lp)
        A0[lmin:lmax + 1] += 1
    return A0

for i in range(K):
    As = light(As, N)

print(*As,sep=" ")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
L = [0] * len(A)
H = [0] * len(A)
for i in range(len(A)):
  l = i - A[i]
  h = i + A[i]
  if l >= 0:
    L[l] += 1
  else:
    L[0] += 1
  if h < len(A):
    H[h] += 1
S = 0
for i in range(len(A)):
  S += L[i]
  A[i] = S
  l = i - A[i]
  h = i + A[i]
  if l >= 0:
    L[l] += 1
  else:
    L[0] += 1
  if h < len(A):
    H[h] += 1
  S -= H[i]

print(A.split())

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(k):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += int(str(stack)[-1])
        stack = str(stack)
        stack = stack[:len(stack)-1]
        if len(stack):
            stack = int(stack)
        else:
            stack = 0
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += int(str(stack)[-1])
        stack = str(stack)
        stack = stack[:len(stack) - 1]
        if len(stack):
            stack = int(stack)
        else:
            stack = 0
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)

Submission status: Runtime Error

Solution code:
N,K=int(input())
A=list(map(int,input().split()))
for h in range(N):
  for i in range(N):
    count=0
    for j in A:
      if -j-0.5<=0 and 0<=j+0.5:
        count+=1
        A[i]=count
print(' '.join(count))

Submission status: Runtime Error

Solution code:
import numpy as np

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

for _ in range(K):
    field = np.zeros((N, N))

    for i, e in enumerate(A):
        field[i][i] = 1
        field[i][max(0, i - e) : min(N, i + e + 1)] = 1

    A = map(int, np.sum(field, axis=0))

print(*A)

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 = [0] * N
  for j in range(N):
    rng = A_[j]
    for d in range(1, rng):
      if j - d >= 0:
        ltd[j - d] += 1
      if j + d < N:
	    ltd[j + d] += 1
      ltd[j] += 1
    A_ = ltd
    
ans = A_.join(' ')
print(ans)

Submission status: Runtime Error

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

for _ in range(K):
  ans = np.zeros(N)
  for n in range(N):
    temp = np.zeros(N)
    start = n-A[n]
    end = n+A[n]+1
    if start < 0:
      start = 0
    if end > N:
      end = N
    temp[start:end] = [1] * (end-start)
    ans = np.array(ans)+ np.array(temp)
  A = ans
print(" ".join(map(str,list(map(int,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=[0]*n
  cnt=0
  for j in range(n):
    if a[j]>=max(n-j,j)
    cnt+=1
  if cnt==n:
    for j in range(n):
      a[j]=(k-i)*n
    break
  for j in range(n):
    for m in range(j-a[j],j+a[j]+1):
      if 0<=m<=n-1:
        b[m]=b[m]+1
  a=b
for i in a:
  print(i,end=' ')

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()))

    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
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()