結果

問題 No.2053 12345...
ユーザー 👑 CleyL
提出日時 2022-08-21 19:11:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 65,880 KB
最終ジャッジ日時 2025-01-31 02:33:27
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int prev = -2;
    long long tmp = 0;
    long long ans = 0;
    for(int i = 0; n > i; i++){
        int x;cin>>x;
        if(x-prev == 1){
            tmp++;
        }else{
            ans += tmp*(tmp-1)/2;
            tmp = 1;
        }
        prev = x;
    }
    ans += tmp*(tmp-1)/2;
    cout << ans << endl;
}
0