21072022-12-20 07:32:24gkataSíkság (55)cpp17Wrong answer 35/5535ms5316 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,mdb,mmaxi=INT_MIN,mkezd,mkmax;

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];
    mkezd=0;
    mdb=0;

    for(i=1;i<=n;++i)
    {
        if(x[i]==a || x[i]==(a-1))
        {
                ++mdb;
                if(mdb>mmaxi)
                {
                    mmaxi=mdb;
                    mkmax=mkezd;
                }
        }

        else
        {
            mdb=0;
            a=x[i];
            mkezd=i;
        }

    }

    if(maxi>mmaxi) cout<<maxi+1<<" "<<kmax+1;
    else if(mmaxi>maxi) cout<<mmaxi+1<<" "<<mkmax+1;
    else if(mmaxi==maxi)
    {
        if(kmax<mkmax) cout<<maxi+1<<" "<<kmax+1;
            else cout<<mmaxi+1<<" "<<mkmax+1;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/55
1Accepted0/03ms1876 KiB
2Wrong answer0/04ms2352 KiB
3Accepted2/22ms2324 KiB
4Accepted2/22ms2472 KiB
5Wrong answer0/22ms2548 KiB
6Accepted2/22ms2676 KiB
7Wrong answer0/32ms2880 KiB
8Accepted2/22ms3100 KiB
9Accepted3/32ms3172 KiB
10Wrong answer0/34ms3524 KiB
11Wrong answer0/34ms3724 KiB
12Accepted3/34ms3676 KiB
13Wrong answer0/332ms4704 KiB
14Wrong answer0/319ms4700 KiB
15Wrong answer0/327ms4700 KiB
16Accepted3/335ms4796 KiB
17Accepted3/335ms4800 KiB
18Accepted3/334ms4796 KiB
19Accepted3/334ms4928 KiB
20Accepted3/334ms5132 KiB
21Accepted3/318ms4712 KiB
22Accepted3/327ms5316 KiB