18972022-12-08 10:07:17BenceSíkság (55)cpp11Wrong answer 23/55272ms4172 KiB
#include <iostream>
#include <vector>
using namespace std;

int maxi,i,n,j,db,dbb,poz;

vector <int> x;

int main()
{
    cin>>n;
    x.resize(n+1);
    for(i=1; i<=n; ++i)
    {
        cin>>x[i];

        if(x[i]==x[i-1])
        {
            db=0;
            for(j=i-1; j>0; --j)
                if(x[j]==x[i] || x[j]==x[i]+1)
                    ++db;
                else break;
            dbb=0;
            if(db>maxi){
                maxi=db;
                poz=i;
            }
            for(j=i-1; j>0; --j)
                if(x[j]==x[i] || x[j]==x[i]-1)
                    ++dbb;
                else break;
            if(dbb>maxi){
                maxi=dbb;
                poz=i;
            }
        }else if(x[i-1]==x[i]+1)
        {
            db=0;
            for(j=i-1; j>0; --j)
                if(x[j]==x[i] || x[j]==x[i]+1)
                    ++db;
                else break;
            dbb=0;
            if(db>maxi){
                maxi=db;
                poz=i;}
        }else if(x[i-1]==x[i]-1)
        {
            dbb=0;
            if(db>maxi){
                maxi=db;
                poz=i;
            }
            for(j=i-1; j>0; --j)
                if(x[j]==x[i] || x[j]==x[i]-1)
                    ++dbb;
                else break;
            if(dbb>maxi){
                maxi=dbb;
                poz=i;
            }
        }
    }
    cout<<maxi+1<<' '<<poz-maxi;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/55
1Accepted0/03ms1748 KiB
2Accepted0/019ms1952 KiB
3Accepted2/22ms2116 KiB
4Accepted2/22ms2504 KiB
5Wrong answer0/22ms2648 KiB
6Accepted2/22ms2840 KiB
7Accepted3/32ms2940 KiB
8Accepted2/23ms2944 KiB
9Accepted3/33ms3188 KiB
10Accepted3/314ms3468 KiB
11Accepted3/34ms3368 KiB
12Time limit exceeded0/3252ms3440 KiB
13Accepted3/335ms4172 KiB
14Time limit exceeded0/3272ms3128 KiB
15Time limit exceeded0/3270ms3364 KiB
16Time limit exceeded0/3225ms3364 KiB
17Time limit exceeded0/3254ms3404 KiB
18Time limit exceeded0/3261ms3548 KiB
19Time limit exceeded0/3217ms3508 KiB
20Time limit exceeded0/3268ms3636 KiB
21Time limit exceeded0/3256ms3644 KiB
22Time limit exceeded0/3264ms3680 KiB