結果

問題 No.2053 12345...
ユーザー デカブツデカブツ
提出日時 2022-08-21 13:54:14
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,723 bytes
コンパイル時間 10,195 ms
コンパイル使用メモリ 168,308 KB
実行使用メモリ 210,796 KB
最終ジャッジ日時 2024-04-18 12:56:11
合計ジャッジ時間 13,984 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
28,800 KB
testcase_01 AC 47 ms
28,408 KB
testcase_02 AC 51 ms
29,568 KB
testcase_03 AC 69 ms
36,068 KB
testcase_04 AC 85 ms
49,152 KB
testcase_05 AC 67 ms
33,920 KB
testcase_06 AC 81 ms
47,104 KB
testcase_07 AC 79 ms
41,600 KB
testcase_08 AC 74 ms
40,960 KB
testcase_09 AC 84 ms
49,024 KB
testcase_10 AC 91 ms
53,856 KB
testcase_11 AC 65 ms
33,792 KB
testcase_12 AC 64 ms
32,512 KB
testcase_13 AC 88 ms
53,376 KB
testcase_14 AC 72 ms
38,656 KB
testcase_15 AC 68 ms
36,736 KB
testcase_16 AC 70 ms
36,352 KB
testcase_17 AC 67 ms
34,304 KB
testcase_18 AC 93 ms
55,008 KB
testcase_19 AC 86 ms
49,920 KB
testcase_20 AC 63 ms
31,488 KB
testcase_21 AC 74 ms
41,344 KB
testcase_22 AC 50 ms
28,800 KB
testcase_23 AC 63 ms
32,896 KB
testcase_24 AC 71 ms
37,120 KB
testcase_25 AC 89 ms
53,120 KB
testcase_26 AC 76 ms
41,472 KB
testcase_27 AC 69 ms
36,592 KB
testcase_28 AC 68 ms
35,840 KB
testcase_29 AC 80 ms
46,688 KB
testcase_30 AC 72 ms
36,224 KB
testcase_31 AC 78 ms
46,592 KB
testcase_32 AC 93 ms
210,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (84 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 System.Collections.Generic;

namespace test
{
    static class Program
    {
        static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            string[] astr = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            for(int i = 0; i < n; i++)
            {
                a[i] = long.Parse(astr[i]);
            }
            long l = 0;
            long r = 0;
            long kosuu = 0;
            while (true)
            {
                if(l == a.Length)
                {
                    break;
                }
                if (l == r)
                {
                    if (l == a.Length - 1)
                    {
                        break;
                    }
                    else
                    {
                        if (a[l] + 1 == a[l + 1])
                        {
                            r++;
                        }
                        else
                        {
                            l++;
                            r++;
                        }
                    }
                }
                else
                {
                    if (r+1 < a.Length && a[r] + 1 == a[r + 1])
                    {
                        r++;
                    }
                    else
                    {
                        kosuu += (r - l+1) * (r - l ) / 2;
                        if(r == a.Length)
                        {
                            break; 
                        }
                        l = r+1;
                        r = l;
                    }
                }
            }
            Console.WriteLine(kosuu);
        }
    }
}
0