結果
問題 |
No.2053 12345...
|
ユーザー |
|
提出日時 | 2022-08-27 08:37:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 570 bytes |
コンパイル時間 | 2,129 ms |
コンパイル使用メモリ | 195,256 KB |
最終ジャッジ日時 | 2025-01-31 06:08:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ll n; std::cin >> n; vector<ll> a(n),b; for (int i = 0; i < n; i++) { std::cin >> a[i]; if(i>0){ b.push_back(a[i]-a[i-1]); } } ll ans = 0; ll now = 0; for (int i = 0; i < n-1; i++) { if(b[i]==1){ now++; }else{ ans += now*(now+1)/2; now = 0; } } ans += now*(now+1)/2; std::cout << ans << std::endl; }