21032022-12-20 07:22:11gkataSíkság (55)cpp17Runtime error 0/553ms4656 KiB
//#include <iostream>
#include <fstream>
#include <vector>
#include <climits>

using namespace std;

ifstream cin("sik.in");
ofstream cout("sik.out");

vector <int> x;

int n,i,a,db,maxi=INT_MIN,kezd,kmax;

int main()
{
    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>a;
        x.push_back(a);
    }

    a=x[0];
    kezd=0;
    db=0;
    for(i=1;i<=n;++i)
    {
        if(x[i]==(a+1) || x[i]==a)
        {
                ++db;
                if(db>maxi)
                {
                    maxi=db;
                    kmax=kezd;
                }
        }

        else
        {
            db=0;
            a=x[i];
            kezd=i;
        }

    }

    a=x[0];
    kezd=0;
    db=0;

    for(i=1;i<=n;++i)
    {
        if(x[i]==a || x[i]==(a-1))
        {
                ++db;
                if(db>maxi)
                {
                    maxi=db;
                    kmax=kezd;
                }
        }

        else
        {
            db=0;
            a=x[i];
            kezd=i;
        }

    }
    cout<<maxi+1<<" "<<kmax+1;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Runtime error0/03ms1780 KiB
2Runtime error0/02ms2128 KiB
3Runtime error0/22ms2268 KiB
4Runtime error0/22ms2548 KiB
5Runtime error0/22ms2800 KiB
6Runtime error0/22ms3004 KiB
7Runtime error0/32ms3052 KiB
8Runtime error0/22ms3080 KiB
9Runtime error0/32ms3284 KiB
10Runtime error0/32ms3400 KiB
11Runtime error0/32ms3432 KiB
12Runtime error0/32ms3696 KiB
13Runtime error0/32ms3652 KiB
14Runtime error0/32ms3608 KiB
15Runtime error0/32ms3528 KiB
16Runtime error0/32ms3944 KiB
17Runtime error0/32ms4040 KiB
18Runtime error0/32ms4244 KiB
19Runtime error0/32ms4176 KiB
20Runtime error0/32ms4588 KiB
21Runtime error0/32ms4588 KiB
22Runtime error0/32ms4656 KiB