Article From:https://www.cnblogs.com/mch5201314/p/9970248.html

Subject Meaning

There are columns ranging from small to large, ranging from 1 to 1000. Ask how many digits you can get rid of to recover.
Write it down because wrong has a lot of hair.

Code

#include<bits/stdc++.h> 
using namespace std;
#define N 100000+5
int a[N];
int main()
{
    int i, j, k;
    int n, m;
    cin>>n;
    for(i=0; i<n; i++)
        cin>>a[i];
    int co=0, maxn=0;
    for(i=0; i<n; i++)
    {
        if(!i && a[i+1]==2)
        co++;
        else if(i==n-1 && a[n-2]==999)
            co++;
        else 
        {
            if(a[i]==a[i-1]+1 && a[i]==a[i+1]-1)
        co++;
        else maxn=max(maxn, co), co=0;
        } 
    } 
    maxn=max(maxn, co);
    cout<<maxn<<endl;
    return 0;
}
Link of this Article: A. A Prank

Leave a Reply

Your email address will not be published. Required fields are marked *