結果

問題 No.2053 12345...
ユーザー bluemeganebluemegane
提出日時 2022-08-27 10:11:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 112,836 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-04-22 09:37:03
合計ジャッジ時間 6,128 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
18,176 KB
testcase_01 AC 27 ms
17,920 KB
testcase_02 AC 32 ms
18,688 KB
testcase_03 AC 45 ms
22,784 KB
testcase_04 AC 80 ms
34,432 KB
testcase_05 AC 41 ms
20,096 KB
testcase_06 AC 78 ms
33,408 KB
testcase_07 AC 61 ms
26,240 KB
testcase_08 AC 59 ms
25,728 KB
testcase_09 AC 84 ms
34,688 KB
testcase_10 AC 99 ms
37,632 KB
testcase_11 AC 40 ms
20,324 KB
testcase_12 AC 36 ms
20,096 KB
testcase_13 AC 99 ms
37,376 KB
testcase_14 AC 50 ms
23,040 KB
testcase_15 AC 49 ms
23,172 KB
testcase_16 AC 48 ms
23,040 KB
testcase_17 AC 42 ms
20,736 KB
testcase_18 AC 114 ms
41,472 KB
testcase_19 AC 86 ms
35,072 KB
testcase_20 AC 36 ms
19,456 KB
testcase_21 AC 61 ms
25,984 KB
testcase_22 AC 32 ms
18,432 KB
testcase_23 AC 37 ms
19,984 KB
testcase_24 AC 48 ms
23,524 KB
testcase_25 AC 96 ms
36,992 KB
testcase_26 AC 60 ms
26,112 KB
testcase_27 AC 48 ms
23,224 KB
testcase_28 AC 45 ms
22,144 KB
testcase_29 AC 78 ms
33,024 KB
testcase_30 AC 47 ms
23,040 KB
testcase_31 AC 75 ms
32,512 KB
testcase_32 AC 102 ms
38,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var b = new List<int>();
        var tc = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i] - a[i - 1] == 1) tc++;
            else
            {
                if (tc > 0) b.Add(tc);
                tc = 0;
            }
        }
        if (tc > 0) b.Add(tc);
        var ans = 0L;
        foreach (var x in b)
            ans += (long)x * (x + 1) / 2L;
        Console.WriteLine(ans);
    }
}
0