結果

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

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

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

for i in range(N-1):
    d = A[i+1]-A[i]
    
    if d==1:
        cnt += 1
    else:
        ans += cnt*(cnt+1)//2
        cnt = 0

ans += cnt*(cnt+1)//2
print(ans)
0