結果

問題 No.2053 12345...
ユーザー aaaaaaaaaa2230
提出日時 2022-08-21 13:31:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 107,520 KB
最終ジャッジ日時 2024-10-10 06:05:32
合計ジャッジ時間 4,138 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int,input().split())) + [10**10]
ans = 0
last = -1
count = 0
for i,a in enumerate(A):
    if last == -1:
        last = a
        count += 1
        
    else:
        if a == last+1:
            count += 1
        else:
            ans += count*(count-1)//2
            count = 1
    last = a
print(ans)
0