Files
python/TangDou/LuoGuBook/P1420_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

33 lines
571 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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