题解
2025-08-02 14:22:39
发布于:浙江
5阅读
0回复
0点赞
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int s=1;
int a[100010];
vector<int>maxs;
int n;
cin >> n;
if (n==0 || n==1){cout<<n;return 0;}
for (int i=1;i<=n;i++) cin >> a[i];
for (int i=2;i<=n;i++){
if (a[i-1]+1==a[i]) s++;
else s=1;
maxs.push_back(s);
}
sort(maxs.begin(),maxs.end(),greater<>());
cout << maxs[0];
return 0;
}
这里空空如也
有帮助,赞一个