You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
571 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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;
}