結果

問題 No.2053 12345...
コンテスト
ユーザー dango
提出日時 2023-06-14 19:25:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 97 ms / 2,000 ms
+ 957µs
コード長 330 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 242 ms
コンパイル使用メモリ 95,804 KB
実行使用メモリ 115,968 KB
最終ジャッジ日時 2026-07-27 13:37:18
合計ジャッジ時間 5,226 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def C(n, A):
    count = 0
    i = 0
    while i < n:
        j = i + 1
        while j < n and A[j] - A[j - 1] == 1:
            j += 1
        length = j - i
        if length >= 2:
            count += (length - 1) * length // 2
        i = j
    return count
N = int(input())
A = list(map(int, input().split()))
print(C(N, A))
0