結果

問題 No.1505 Zero-Product Ranges
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-16 22:26:54
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 10,255 ms
コンパイル使用メモリ 167,644 KB
実行使用メモリ 187,800 KB
最終ジャッジ日時 2024-06-16 22:27:13
合計ジャッジ時間 17,448 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
30,048 KB
testcase_01 AC 53 ms
30,200 KB
testcase_02 AC 52 ms
29,824 KB
testcase_03 AC 84 ms
43,496 KB
testcase_04 AC 96 ms
43,136 KB
testcase_05 AC 73 ms
36,352 KB
testcase_06 AC 72 ms
36,072 KB
testcase_07 AC 69 ms
34,560 KB
testcase_08 AC 80 ms
35,448 KB
testcase_09 AC 69 ms
34,688 KB
testcase_10 AC 71 ms
34,920 KB
testcase_11 AC 76 ms
36,352 KB
testcase_12 AC 74 ms
34,284 KB
testcase_13 AC 79 ms
38,400 KB
testcase_14 AC 74 ms
36,992 KB
testcase_15 AC 84 ms
42,624 KB
testcase_16 AC 85 ms
43,136 KB
testcase_17 AC 87 ms
43,136 KB
testcase_18 AC 89 ms
43,136 KB
testcase_19 AC 56 ms
30,200 KB
testcase_20 AC 54 ms
30,336 KB
testcase_21 AC 52 ms
30,336 KB
testcase_22 AC 95 ms
42,876 KB
testcase_23 AC 89 ms
43,136 KB
testcase_24 AC 91 ms
42,496 KB
testcase_25 AC 85 ms
42,368 KB
testcase_26 AC 90 ms
42,752 KB
testcase_27 AC 88 ms
42,752 KB
testcase_28 AC 90 ms
42,624 KB
testcase_29 AC 89 ms
43,264 KB
testcase_30 AC 91 ms
43,264 KB
testcase_31 AC 89 ms
42,752 KB
testcase_32 AC 77 ms
37,248 KB
testcase_33 AC 75 ms
36,864 KB
testcase_34 AC 85 ms
37,248 KB
testcase_35 AC 73 ms
36,224 KB
testcase_36 AC 73 ms
35,956 KB
testcase_37 AC 74 ms
37,120 KB
testcase_38 AC 73 ms
36,736 KB
testcase_39 AC 73 ms
36,736 KB
testcase_40 AC 72 ms
36,992 KB
testcase_41 AC 78 ms
38,144 KB
testcase_42 AC 69 ms
32,128 KB
testcase_43 AC 67 ms
32,640 KB
testcase_44 AC 67 ms
32,256 KB
testcase_45 AC 66 ms
32,256 KB
testcase_46 AC 54 ms
30,848 KB
testcase_47 AC 67 ms
32,252 KB
testcase_48 AC 74 ms
32,232 KB
testcase_49 AC 59 ms
30,592 KB
testcase_50 AC 65 ms
32,000 KB
testcase_51 AC 63 ms
187,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (91 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var ans = (long)n * (n + 1) / 2;
        var tmp = 0L;
        for (var i = 0; i < n; ++i)
        {
            if (a[i] == 0)
            {
                ans -= tmp * (tmp + 1) / 2;
                tmp = 0;
            }
            else ++tmp;
        }
        WriteLine(ans - tmp * (tmp + 1) / 2);
    }
}
0