結果

問題 No.2053 12345...
コンテスト
ユーザー DrDrpilot
提出日時 2022-08-23 18:18:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 451 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 197 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 114,432 KB
最終ジャッジ日時 2026-04-27 07:50:53
合計ジャッジ時間 4,435 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def I():return int(input())
def MAP():return map(int,input().split())
def LIST(): return list(map(int,input().split()))
def S():return input()
from collections import deque
n=I()
a=LIST()
q=deque()
ans=0
for i in a:
    if len(q)==0:
        q.append(i)
        continue
    if q[-1]+1==i:
        q.append(i)
    else:
        ans+=len(q)*(len(q)-1)//2
        while q:
            q.popleft()
        q.append(i)
ans+=len(q)*(len(q)-1)//2
print(ans)
0