結果

問題 No.2053 12345...
ユーザー nonon
提出日時 2024-09-12 12:04:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 195,088 KB
最終ジャッジ日時 2025-02-24 06:43:01
ジャッジサーバーID
(参考情報)
judge5 / 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=0;i<N;i++)cin>>A[i];
    long ans=0;
    for(int i=1;i<N;)
    {
        int j=i;
        while(j<N&&A[j-1]==A[j]-1)j++,ans+=j-i;
        i=j+1;
    }
    cout<<ans<<endl;
}
0