33 lines
571 B
C++
33 lines
571 B
C++
|
|
#include <bits/stdc++.h>
|
|||
|
|
using namespace std;
|
|||
|
|
const int N = 1e4 + 10;
|
|||
|
|
|
|||
|
|
//常数,正无穷大
|
|||
|
|
const int INF = 0x3f3f3f3f;
|
|||
|
|
|
|||
|
|
int a[N];
|
|||
|
|
int Max = -INF, len = 1;
|
|||
|
|
/*
|
|||
|
|
1 1
|
|||
|
|
|
|||
|
|
一个数字,这个数字是1
|
|||
|
|
最长的连续长度是几?
|
|||
|
|
1
|
|||
|
|
|
|||
|
|
*/
|
|||
|
|
int main() {
|
|||
|
|
int n;
|
|||
|
|
cin >> n;
|
|||
|
|
for (int i = 1; i <= n; i++) {
|
|||
|
|
cin >> a[i];
|
|||
|
|
if (i > 1) {
|
|||
|
|
if (a[i] - a[i - 1] == 1)
|
|||
|
|
len++;
|
|||
|
|
else
|
|||
|
|
len = 1;
|
|||
|
|
}
|
|||
|
|
Max = max(Max, len);
|
|||
|
|
}
|
|||
|
|
cout << Max << endl;
|
|||
|
|
return 0;
|
|||
|
|
}
|