結果

問題 No.2053 12345...
ユーザー rlangevin
提出日時 2022-12-30 02:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 99,988 KB
最終ジャッジ日時 2024-11-25 00:39:19
合計ジャッジ時間 3,300 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))

ans = 0
pre = -1
cnt = 0
for a in A:
    if a == pre + 1:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1
    pre = a
    
ans += cnt * (cnt - 1) // 2
print(ans)
0