結果

問題 No.833 かっこいい電車
ユーザー NoNo
提出日時 2019-06-20 19:11:09
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 2,285 bytes
コンパイル時間 3,651 ms
コンパイル使用メモリ 107,068 KB
実行使用メモリ 52,144 KB
最終ジャッジ日時 2023-09-14 21:07:55
合計ジャッジ時間 8,948 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace a
{
    class y
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var n = int.Parse(ss[0]);
            var q = int.Parse(ss[1]);
            var a = new long[n + 1];
            var c = new bool[n + 1];
            var ans = "";

            ss =Console.ReadLine().Split();
            for (int i = 0; i < ss.Length; i++)
            {
                a[i + 1] = long.Parse(ss[i]);
            }

            for (int i = 0; i < q; i++)
            {
                ss = Console.ReadLine().Split();
                
                switch (ss[0])
                {
                    case "1":
                        if (int.Parse(ss[1]) < n)
                        {
                            c[int.Parse(ss[1]) + 1] = true;
                        }

                        break;
                    case "2":
                        if (int.Parse(ss[1]) < n)
                        {
                            c[int.Parse(ss[1]) + 1] = false;
                        }

                        break;
                    case "3":
                        if (int.Parse(ss[1]) < n + 1)
                        {
                            a[int.Parse(ss[1])]++;
                        }

                        break;
                    case "4":

                        long w = 0;
                        if (int.Parse(ss[1]) < n + 1)
                        {
                            w = a[int.Parse(ss[1])];
                            var y = int.Parse(ss[1]) + 1;
                            while (y < n + 1 && c[y])
                            {
                                w += a[y];
                                y++;
                            }

                            y = int.Parse(ss[1]);
                            while (c[y])
                            {
                                w += a[int.Parse(ss[1]) - 1];
                                y--;
                            }
                        }
                        ans += w.ToString() + "\n";

                        break;
                    default:
                        break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}
0