21042022-12-20 07:23:12gkataSíkság (55)cpp17Wrong answer 35/5535ms4976 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
base35/55
1Accepted0/03ms1872 KiB
2Wrong answer0/04ms2356 KiB
3Accepted2/22ms2324 KiB
4Accepted2/22ms2400 KiB
5Wrong answer0/22ms2536 KiB
6Accepted2/22ms2680 KiB
7Wrong answer0/32ms2792 KiB
8Accepted2/22ms2800 KiB
9Accepted3/32ms3024 KiB
10Wrong answer0/34ms3416 KiB
11Wrong answer0/34ms3216 KiB
12Accepted3/34ms3148 KiB
13Wrong answer0/332ms4308 KiB
14Wrong answer0/319ms4512 KiB
15Wrong answer0/326ms4604 KiB
16Accepted3/334ms4648 KiB
17Accepted3/335ms4732 KiB
18Accepted3/335ms4808 KiB
19Accepted3/335ms4840 KiB
20Accepted3/335ms4892 KiB
21Accepted3/318ms4480 KiB
22Accepted3/328ms4976 KiB