結果
| 問題 |
No.2053 12345...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-23 17:52:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 118 ms / 2,000 ms |
| コード長 | 341 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 82,212 KB |
| 実行使用メモリ | 99,608 KB |
| 最終ジャッジ日時 | 2024-10-11 01:39:31 |
| 合計ジャッジ時間 | 3,938 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
from collections import deque
n=int(input())
a=list(map(int,input().split()))
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)