题解
2025-07-30 15:33:56
发布于:湖南
11阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],longest=1,maxn;
int main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=2;i<=n;i++){
if(a[i]-1==a[i-1])longest++;
else {maxn=max(maxn,longest);longest=1;}
}
maxn=max(maxn,longest);
cout<<maxn;
return 0;
}
这里空空如也
有帮助,赞一个