結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  long long ans=0,cnt=0;
  A.push_back(0);
  for(int i=1;i<=N;i++){
    if(A[i]-1==A[i-1])++cnt;
    else ans+=cnt*(cnt+1)/2,cnt=0;
  }
  cout<<ans<<'\n';
}
0