結果

問題 No.1673 Lamps on a line
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-03 22:16:25
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 7,141 ms
コンパイル使用メモリ 158,460 KB
実行使用メモリ 210,088 KB
最終ジャッジ日時 2024-01-03 22:16:50
合計ジャッジ時間 11,289 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
32,804 KB
testcase_01 AC 79 ms
32,804 KB
testcase_02 AC 125 ms
44,836 KB
testcase_03 AC 110 ms
44,836 KB
testcase_04 AC 133 ms
53,668 KB
testcase_05 AC 84 ms
34,212 KB
testcase_06 AC 124 ms
50,468 KB
testcase_07 AC 127 ms
52,388 KB
testcase_08 AC 82 ms
33,444 KB
testcase_09 AC 187 ms
59,812 KB
testcase_10 AC 172 ms
62,372 KB
testcase_11 AC 97 ms
35,876 KB
testcase_12 AC 196 ms
210,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (97 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, q) = (c[0], c[1]);
        var map = NArr(q);
        var ans = new int[q];
        var lamp = new bool[n];
        var tmp = 0;
        for (var i = 0; i < q; ++i)
        {
            for (var j = map[i][0] - 1; j < map[i][1]; ++j)
            {
                if (lamp[j]) --tmp;
                else ++tmp;
                lamp[j] = !lamp[j];
            }
            ans[i] = tmp;
        }
        WriteLine(string.Join("\n", ans));
    }
}
0