結果
問題 |
No.2053 12345...
|
ユーザー |
![]() |
提出日時 | 2022-11-11 07:30:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 465 bytes |
コンパイル時間 | 1,563 ms |
コンパイル使用メモリ | 196,604 KB |
最終ジャッジ日時 | 2025-02-08 19:39:42 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N; cin>>N; vector<int> S(N); for(int i=0;i<N;i++) cin>>S[i]; vector<int> T={}; int now = 1; for(int i=1;i<N;i++){ if(S[i] == S[i-1]+1) now++; else{ T.push_back(now); now = 1; } } T.push_back(now); int ans = 0; for(int i=0;i<T.size();i++) ans += T[i]*(T[i]-1)/2; cout<<ans<<endl; }