結果

問題 No.2053 12345...
ユーザー デカブツデカブツ
提出日時 2022-08-21 13:54:14
言語 C#
(.NET 7.0.402)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,723 bytes
コンパイル時間 7,015 ms
コンパイル使用メモリ 142,156 KB
実行使用メモリ 180,992 KB
最終ジャッジ日時 2023-07-31 12:41:21
合計ジャッジ時間 10,867 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
28,212 KB
testcase_01 AC 47 ms
28,448 KB
testcase_02 AC 47 ms
28,652 KB
testcase_03 AC 56 ms
32,956 KB
testcase_04 AC 73 ms
42,540 KB
testcase_05 AC 55 ms
33,136 KB
testcase_06 AC 70 ms
38,612 KB
testcase_07 AC 68 ms
38,864 KB
testcase_08 AC 63 ms
36,348 KB
testcase_09 AC 72 ms
42,744 KB
testcase_10 AC 80 ms
46,532 KB
testcase_11 AC 53 ms
30,716 KB
testcase_12 AC 52 ms
29,792 KB
testcase_13 AC 80 ms
47,716 KB
testcase_14 AC 57 ms
33,980 KB
testcase_15 AC 58 ms
33,360 KB
testcase_16 AC 55 ms
32,732 KB
testcase_17 AC 56 ms
31,588 KB
testcase_18 AC 83 ms
47,348 KB
testcase_19 AC 74 ms
42,916 KB
testcase_20 AC 50 ms
29,364 KB
testcase_21 AC 68 ms
38,772 KB
testcase_22 AC 48 ms
28,140 KB
testcase_23 AC 52 ms
30,372 KB
testcase_24 AC 56 ms
33,668 KB
testcase_25 AC 78 ms
47,736 KB
testcase_26 AC 67 ms
38,932 KB
testcase_27 AC 56 ms
33,164 KB
testcase_28 AC 56 ms
32,372 KB
testcase_29 AC 69 ms
38,416 KB
testcase_30 AC 56 ms
34,796 KB
testcase_31 AC 69 ms
41,176 KB
testcase_32 AC 82 ms
180,992 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 119 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.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