結果
| 問題 | No.2053 12345... |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-23 18:18:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 114 ms / 2,000 ms |
| コード長 | 451 bytes |
| 記録 | |
| コンパイル時間 | 414 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 99,992 KB |
| 最終ジャッジ日時 | 2024-10-11 01:59:21 |
| 合計ジャッジ時間 | 4,191 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
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)