東大卒のお金やりくり奮闘記~株、家計、趣味、経済~

東大卒でメーカー勤務の私がセミリタイアするために投資などを頑張っていこうという趣旨で始めたブログです。既婚男性です。株、家計、趣味、経済の話をメインにゆるゆる話します。

東京海上日動で書いたコード

using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string args)
        {
            //問題クラスを展開
            ProgramC a = new ProgramC();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {
            //入力
            string s = Console.ReadLine();

            //頭から3文字出力
            Console.WriteLine(s.Substring(0,3));

        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            string s1 = Console.ReadLine().Split(' ');
            long a = long.Parse(s1[0]);
            long v = long.Parse(s1[1]);
            string s2Console.ReadLine().Split(' ');
            long b = long.Parse(s2[0]);
            long w = long.Parse(s2[1]);
            long t = long.Parse(Console.ReadLine());

            //最大縮められる距離
            long temp = t * (v - w);

            //距離がそれ以上かどうかで判断
            if (temp >= Math.Abs(a - b))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }

    class ProgramC
    {
        public void main()
        {
            //入力
            string s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            string a1 = Console.ReadLine().Split(' ');

            long a = new long[n];

            //最初のa
            for (int i = 0i < ni++)
                a[i] = long.Parse(a1[i]);


            //実はlogNで十分なのでx =50で打ち止めしちゃう
            for (int x = 0x < kx++)
            {
                //次のbiを累積和で出す
                long[] b = new long[n];
                for (int i = 0i < ni++)
                {
                    //左端と右端を記録
                    long l = Math.Max(0i - a[i]);
                    long r = Math.Min(n - 1i + a[i]);
                    b[l]++;//左端を足す
                    //右端+1を引くことで終わりを示す
                    if (r + 1 < n)
                        b[r + 1]--;

                }

                //左から足すと前の情報が残っているので使える
                for (int i = 1i < ni++)
                    b[i] += b[i - 1];

                //aを更新
                for (int i = 0i < ni++)
                    a[i] = b[i];

                //問題的にlogN(40数回)で十分
                if (x == 50)
                    break;
            }

            //答え出力
            for (int i = 0i < ni++)
                Console.Write(a[i] + " ");
        }
    }
}