結果

問題 No.2053 12345...
ユーザー kokatsukokatsu
提出日時 2022-10-14 00:49:37
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 206,028 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2023-09-04 18:34:06
合計ジャッジ時間 5,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 11 ms
7,004 KB
testcase_04 AC 29 ms
9,300 KB
testcase_05 AC 8 ms
4,536 KB
testcase_06 AC 26 ms
9,528 KB
testcase_07 AC 18 ms
6,700 KB
testcase_08 AC 18 ms
7,400 KB
testcase_09 AC 29 ms
8,716 KB
testcase_10 AC 37 ms
10,508 KB
testcase_11 AC 7 ms
4,532 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 38 ms
10,152 KB
testcase_14 AC 14 ms
5,676 KB
testcase_15 AC 12 ms
5,604 KB
testcase_16 AC 12 ms
5,564 KB
testcase_17 AC 9 ms
4,444 KB
testcase_18 AC 42 ms
13,184 KB
testcase_19 AC 31 ms
9,016 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 19 ms
7,716 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 13 ms
7,664 KB
testcase_25 AC 36 ms
11,240 KB
testcase_26 AC 18 ms
7,652 KB
testcase_27 AC 13 ms
6,592 KB
testcase_28 AC 10 ms
4,620 KB
testcase_29 AC 26 ms
9,172 KB
testcase_30 AC 11 ms
6,720 KB
testcase_31 AC 24 ms
8,476 KB
testcase_32 AC 41 ms
12,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long N;
    readf("%d\n", N);

    auto A = readln.chomp.split.to!(long[]);

    long res, r;
    foreach (l; 0 .. N-1) {
        while (r < N -1 && A[r] + 1 == A[r+1]) {
            ++r;
        }

        res += r - l;

        if (l == r) ++r;
    }

    res.writeln;
}
0