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

Solution in C# (.NET Core 3.1.201) (judge verdict: Time Limit Exceeded)

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Tokiomarine2020
{
    using static Ex;
    public class Solve
    {
        public static void Main(string[] args)
        {
            new Tokiomarine2020_C();
        }
    }
    public class Tokiomarine2020_A
    {
        public Tokiomarine2020_A()
        {
            var s = Read;
            s.Substring(0, 3).Cw();
        }
    }
    public class Tokiomarine2020_B
    {
        long a, b, v, w, t;
        public Tokiomarine2020_B()
        {
            (a, v) = ReadLongArray().ToTpl2();
            (b, w) = ReadLongArray().ToTpl2();
            t = ReadLong;

            bool bo = false;
            var d = v - w;
            if (v > w)
            {
                bo = t * d >= Math.Abs(a - b);
            }
            bo.YESNO();
        }
    }
    public class Tokiomarine2020_C
    {
        long n, k;
        long[] a;
        public Tokiomarine2020_C()
        {
            (n, k) = ReadLongArray().ToTpl2();
            a = ReadLongArray();

            var arr = new long[n];

            //操作時に座標iを照らしている電球の個数をBiとする。そして、各電球iの光の強さをBiに変更
            for (long i = 0; i < k; i++)
            {
                if (i % 2 == 0)
                {
                    I(ref a, ref arr);
                    if (arr.All(v => v == n)) break;
                }
                else
                {
                    I(ref arr, ref a);
                    if (a.All(v => v == n)) break;
                }
            }
            if (k % 2 == 0) string.Join(" ", a).Cw();
            else string.Join(" ", arr).Cw();
        }

        void I(ref long[] a, ref long[] arr)
        {
            var ms = new MultiSet<double>();

            //座標xに光の強さdの電球があるとき、その電球は座標x−d−0.5から座標x+d+0.5まで
            for (long x = 0; x < n; x++)
            {
                ms.Insert(x + a[x] + .5);
                var j = ms.LowerBound(x);
                var tpl = SB_BinarySearchTree<double>.Split(ms._root, j);
                ms._root = tpl.Item2;
                //var v = ms.Peek;
                //var j = n - ms.Peek.Item1;
                //while (j < x)
                //{
                //    ms.Pop();
                //    if (ms.Count() == 0) break;
                //    v = ms.Peek;
                //    j = n - v.Item1;
                //}
                arr[x] = ms.Count();
                //$"{x} pq.Count{ms.Count()}".Cw();
            }
            //string.Join(" ", arr).Cw();
            ms = new MultiSet<double>();
            for (long x = n - 1; x >= 0; x--)
            {
                if (ms.Count() == 0)
                {
                    ms.Insert(x - a[x] - .5);
                    continue;
                }
                var j = ms.UpperBound(x);
                var tpl = SB_BinarySearchTree<double>.Split(ms._root, j);
                ms._root = tpl.Item1;
                //var v = ms.Peek;
                //var j = v.Item1;
                ////$"0: {v.Item2} {j}".Cw();
                //while (j > x)
                //{
                //    ms.Pop();
                //    if (ms.Count == 0) break;
                //    v = ms.Peek;
                //    j = v.Item1;
                //    //$"1: {v.Item2} {j}".Cw();
                //}
                arr[x] += ms.Count();
                ms.Insert(x - a[x] - .5);
                //$"{x} pq.Count{ms.Count()}".Cw();
            }
        }
    }
    public class Tokiomarine2020_D
    {
        public Tokiomarine2020_D()
        {
            // N 個 容量 W
            int n = ReadInt;
            // 重さはwiで、価値はvi
            var weight = new int[n];
            var value = new int[n];
            for (int i = 0; i < n; i++)
            {
                (value[i], weight[i]) = ReadIntArray().ToTpl2();
            }

            //var dp = new long[n + 1, W + 1];
            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j <= W; j++)
            //    {
            //        // i 番目の品物を選ぶ場合
            //        if (j - weight[i] >= 0)
            //        {
            //            dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j - weight[i]] + value[i]);
            //        }

            //        // i 番目の品物を選ばない場合
            //        dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);
            //    }
            //}
            //dp[n, W].Cw();
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }


        static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }

        /// <summary>
        /// Self-Balancing Binary Search Tree
        /// (using Randamized BST)
        /// </summary>
        public class SB_BinarySearchTree<T> where T : IComparable
        {
            public class Node
            {
                public T Value;
                public Node LChild;
                public Node RChild;
                public int Count;     //size of the sub tree

                public Node(T v)
                {
                    Value = v;
                    Count = 1;
                }
            }

            static Random _rnd = new Random();

            public static int Count(Node t)
            {
                return t == null ? 0 : t.Count;
            }

            static Node Update(Node t)
            {
                t.Count = Count(t.LChild) + Count(t.RChild) + 1;
                return t;
            }

            public static Node Merge(Node l, Node r)
            {
                if (l == null || r == null) return l == null ? r : l;

                if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble())
                {
                    l.RChild = Merge(l.RChild, r);
                    return Update(l);
                }
                else
                {
                    r.LChild = Merge(l, r.LChild);
                    return Update(r);
                }
            }

            /// <summary>
            /// split as [0, k), [k, n)
            /// </summary>
            public static Tuple<Node, Node> Split(Node t, int k)
            {
                if (t == null) return new Tuple<Node, Node>(null, null);
                if (k <= Count(t.LChild))
                {
                    var s = Split(t.LChild, k);
                    t.LChild = s.Item2;
                    return new Tuple<Node, Node>(s.Item1, Update(t));
                }
                else
                {
                    var s = Split(t.RChild, k - Count(t.LChild) - 1);
                    t.RChild = s.Item1;
                    return new Tuple<Node, Node>(Update(t), s.Item2);
                }
            }

            public static Node Remove(Node t, T v)
            {
                if (Find(t, v) == null) return t;
                return RemoveAt(t, LowerBound(t, v));
            }

            public static Node RemoveAt(Node t, int k)
            {
                var s = Split(t, k);
                var s2 = Split(s.Item2, 1);
                return Merge(s.Item1, s2.Item2);
            }

            public static bool Contains(Node t, T v)
            {
                return Find(t, v) != null;
            }

            public static Node Find(Node t, T v)
            {
                while (t != null)
                {
                    var cmp = t.Value.CompareTo(v);
                    if (cmp > 0) t = t.LChild;
                    else if (cmp < 0) t = t.RChild;
                    else break;
                }
                return t;
            }

            public static Node FindByIndex(Node t, int idx)
            {
                if (t == null) return null;

                var currentIdx = Count(t) - Count(t.RChild) - 1;
                while (t != null)
                {
                    if (currentIdx == idx) return t;
                    if (currentIdx > idx)
                    {
                        t = t.LChild;
                        currentIdx -= (Count(t == null ? null : t.RChild) + 1);
                    }
                    else
                    {
                        t = t.RChild;
                        currentIdx += (Count(t == null ? null : t.LChild) + 1);
                    }
                }

                return null;
            }

            public static int UpperBound(Node t, T v)
            {
                var torg = t;
                if (t == null) return -1;

                var ret = Int32.MaxValue;
                var idx = Count(t) - Count(t.RChild) - 1;
                while (t != null)
                {
                    var cmp = t.Value.CompareTo(v);

                    if (cmp > 0)
                    {
                        ret = Math.Min(ret, idx);
                        t = t.LChild;
                        idx -= (Count(t == null ? null : t.RChild) + 1);
                    }
                    else if (cmp <= 0)
                    {
                        t = t.RChild;
                        idx += (Count(t == null ? null : t.LChild) + 1);
                    }
                }
                return ret == Int32.MaxValue ? Count(torg) : ret;
            }

            public static int LowerBound(Node t, T v)
            {
                var torg = t;
                if (t == null) return -1;

                var idx = Count(t) - Count(t.RChild) - 1;
                var ret = Int32.MaxValue;
                while (t != null)
                {
                    var cmp = t.Value.CompareTo(v);
                    if (cmp >= 0)
                    {
                        if (cmp == 0) ret = Math.Min(ret, idx);
                        t = t.LChild;
                        if (t == null) ret = Math.Min(ret, idx);
                        idx -= t == null ? 0 : (Count(t.RChild) + 1);
                    }
                    else if (cmp < 0)
                    {
                        t = t.RChild;
                        idx += (Count(t == null ? null : t.LChild) + 1);
                        if (t == null) return idx;
                    }
                }
                return ret == Int32.MaxValue ? Count(torg) : ret;
            }

            public static Node Insert(Node t, T v)
            {
                var ub = LowerBound(t, v);
                return InsertByIdx(t, ub, v);
            }

            static Node InsertByIdx(Node t, int k, T v)
            {
                var s = Split(t, k);
                return Merge(Merge(s.Item1, new Node(v)), s.Item2);
            }

            public static IEnumerable<T> Enumerate(Node t)
            {
                var ret = new List<T>();
                Enumerate(t, ret);
                return ret;
            }

            static void Enumerate(Node t, List<T> ret)
            {
                if (t == null) return;
                Enumerate(t.LChild, ret);
                ret.Add(t.Value);
                Enumerate(t.RChild, ret);
            }
        }

        /// <summary>
        /// C-like set
        /// </summary>
        public class Set<T> where T : IComparable
        {
            public SB_BinarySearchTree<T>.Node _root;

            public T this[int idx] { get { return ElementAt(idx); } }

            public int Count()
            {
                return SB_BinarySearchTree<T>.Count(_root);
            }

            public virtual void Insert(T v)
            {
                if (_root == null) _root = new SB_BinarySearchTree<T>.Node(v);
                else
                {
                    if (SB_BinarySearchTree<T>.Find(_root, v) != null) return;
                    _root = SB_BinarySearchTree<T>.Insert(_root, v);
                }
            }

            public void Clear()
            {
                _root = null;
            }

            public void Remove(T v)
            {
                _root = SB_BinarySearchTree<T>.Remove(_root, v);
            }

            public bool Contains(T v)
            {
                return SB_BinarySearchTree<T>.Contains(_root, v);
            }

            public T ElementAt(int k)
            {
                var node = SB_BinarySearchTree<T>.FindByIndex(_root, k);
                if (node == null) throw new IndexOutOfRangeException();
                return node.Value;
            }

            public int Count(T v)
            {
                return SB_BinarySearchTree<T>.UpperBound(_root, v) - SB_BinarySearchTree<T>.LowerBound(_root, v);
            }

            public int LowerBound(T v)
            {
                return SB_BinarySearchTree<T>.LowerBound(_root, v);
            }

            public int UpperBound(T v)
            {
                return SB_BinarySearchTree<T>.UpperBound(_root, v);
            }

            public Tuple<int, int> EqualRange(T v)
            {
                if (!Contains(v)) return new Tuple<int, int>(-1, -1);
                return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v), SB_BinarySearchTree<T>.UpperBound(_root, v) - 1);
            }

            public List<T> ToList()
            {
                return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root));
            }
        }

        /// <summary>
        /// C-like multiset
        /// </summary>
        public class MultiSet<T> : Set<T> where T : IComparable
        {
            public override void Insert(T v)
            {
                if (_root == null) _root = new SB_BinarySearchTree<T>.Node(v);
                else _root = SB_BinarySearchTree<T>.Insert(_root, v);
            }
        }
    }
}