結果

問題 No.1765 While Shining
ユーザー 👑 kakel-sankakel-san
提出日時 2021-11-26 22:46:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 2,823 ms
コンパイル使用メモリ 67,648 KB
実行使用メモリ 39,228 KB
最終ジャッジ日時 2023-09-12 05:19:04
合計ジャッジ時間 5,344 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,484 KB
testcase_01 AC 60 ms
21,492 KB
testcase_02 AC 60 ms
21,536 KB
testcase_03 AC 59 ms
21,584 KB
testcase_04 AC 66 ms
23,664 KB
testcase_05 AC 67 ms
21,668 KB
testcase_06 AC 67 ms
21,564 KB
testcase_07 AC 66 ms
21,588 KB
testcase_08 AC 67 ms
21,724 KB
testcase_09 AC 98 ms
26,676 KB
testcase_10 AC 121 ms
36,928 KB
testcase_11 AC 104 ms
28,032 KB
testcase_12 AC 115 ms
32,680 KB
testcase_13 AC 103 ms
30,008 KB
testcase_14 AC 121 ms
37,208 KB
testcase_15 AC 121 ms
37,188 KB
testcase_16 AC 121 ms
37,212 KB
testcase_17 AC 121 ms
37,216 KB
testcase_18 AC 121 ms
37,200 KB
testcase_19 AC 121 ms
35,212 KB
testcase_20 AC 123 ms
37,196 KB
testcase_21 AC 121 ms
39,228 KB
testcase_22 AC 120 ms
35,152 KB
testcase_23 AC 122 ms
37,132 KB
testcase_24 AC 118 ms
37,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class yuki325
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray();
    static void Main()
    {
        var n = NN;
        var a = NList;
        var cur = 0;
        var res = 0L;
        for (var i = n - 2; i >= 0; --i)
        {
            if (i < n - 2 && a[i] != a[i + 1]) ++cur;
            else cur = 0;
            if (a[i] == 1)
            {
                res += cur + 1;
            }
        }
        WriteLine(res);
    }
}
0