80tps,第四个错了,求助!!
查看原帖
80tps,第四个错了,求助!!
1012972
GoodLooking楼主2023/8/16 16:56
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],maxx,cnt=1,flag;
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]+1==a[i])
        {
            cnt++;
            if(cnt>maxx)maxx=cnt;
        }
        else
        {
            cnt=1;
        }
    }
    if(maxx==0&&flag!=1)cout<<n;
    else cout<<maxx;
    return 0;
}
2023/8/16 16:56
加载中...