21082022-12-20 07:36:39gkataSíkság (55)cpp17Wrong answer 35/5535ms4808 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=1;
    db=1;
    for(i=1;i<=n;++i)
    {
        if(x[i]==(a+1) || x[i]==a)
        {
                ++db;
                if(db>maxi)
                {
                    maxi=db;
                    kmax=kezd;
                }
        }

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

    }

    a=x[0];
    mkezd=1;
    mdb=1;

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

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

    }

    if(maxi>mmaxi) cout<<maxi<<" "<<kmax;
    else if(mmaxi>maxi) cout<<mmaxi<<" "<<mkmax;
    else if(mmaxi==maxi)
    {
        if(kmax<mkmax) cout<<maxi<<" "<<kmax;
            else cout<<mmaxi<<" "<<mkmax;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/55
1Accepted0/03ms1872 KiB
2Wrong answer0/04ms2172 KiB
3Accepted2/22ms2168 KiB
4Accepted2/22ms2520 KiB
5Wrong answer0/22ms2564 KiB
6Accepted2/22ms2764 KiB
7Wrong answer0/32ms3016 KiB
8Accepted2/22ms2980 KiB
9Accepted3/32ms2992 KiB
10Wrong answer0/34ms3088 KiB
11Wrong answer0/34ms3344 KiB
12Accepted3/34ms3296 KiB
13Wrong answer0/332ms4332 KiB
14Wrong answer0/318ms4204 KiB
15Wrong answer0/326ms4332 KiB
16Accepted3/332ms4396 KiB
17Accepted3/334ms4396 KiB
18Accepted3/335ms4396 KiB
19Accepted3/335ms4528 KiB
20Accepted3/334ms4732 KiB
21Accepted3/317ms4296 KiB
22Accepted3/327ms4808 KiB