結果
| 問題 |
No.2053 12345...
|
| コンテスト | |
| ユーザー |
rieaaddlreiuu
|
| 提出日時 | 2022-10-25 18:54:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 454 bytes |
| コンパイル時間 | 1,714 ms |
| コンパイル使用メモリ | 167,032 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 16:35:00 |
| 合計ジャッジ時間 | 3,267 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(){
long length = 0;
int N;
long ans = 0;
scanf("%d",&N);
int a[N];
for(int i=0;i<N;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<N-1;i++){
if(a[i] +1 == a[i+1]){
length++;
} else {
ans += length*(length+1)/2;
length = 0;
}
}
ans += length*(length+1)/2;
printf("%ld",ans);
}
rieaaddlreiuu