結果

問題 No.2053 12345...
コンテスト
ユーザー rlangevin
提出日時 2022-12-30 02:32:58
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 76 ms / 2,000 ms
+ 543µs
コード長 273 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 88 ms
コンパイル使用メモリ 64,628 KB
実行使用メモリ 89,524 KB
最終ジャッジ日時 2026-10-16 16:24:22
合計ジャッジ時間 5,250 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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