結果

問題 No.2053 12345...
ユーザー charmychachacha
提出日時 2022-08-29 22:29:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 191,668 KB
最終ジャッジ日時 2025-02-06 23:39:19
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N;
	int A[200010] = {};
	for(int i = 0; i < N; i++) cin >> A[i];
	long long ans = 0; long long left = 0;
	for(long long i = 1; i <= N; i++){
		if(A[i] == A[i-1] + 1) continue;
		ans += (i - left) * (i - left - 1) / 2;
		left = i;
	}
	cout << ans << "\n";
}
0