18982022-12-08 10:10:10BenceSíkság (55)cpp11Wrong answer 23/55300ms4200 KiB
#include <iostream>
#include <vector>
using namespace std;

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

vector <int> x;

int main()
{
    ios::sync_with_stdio(false);
    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/03ms1892 KiB
2Accepted0/018ms2288 KiB
3Accepted2/22ms2320 KiB
4Accepted2/22ms2492 KiB
5Wrong answer0/22ms2696 KiB
6Accepted2/22ms2900 KiB
7Accepted3/32ms2976 KiB
8Accepted2/23ms2984 KiB
9Accepted3/32ms3112 KiB
10Accepted3/313ms3476 KiB
11Accepted3/34ms3432 KiB
12Time limit exceeded0/3248ms3424 KiB
13Accepted3/316ms4200 KiB
14Time limit exceeded0/3300ms3304 KiB
15Time limit exceeded0/3282ms3512 KiB
16Time limit exceeded0/3254ms3644 KiB
17Time limit exceeded0/3246ms3848 KiB
18Time limit exceeded0/3264ms3888 KiB
19Time limit exceeded0/3273ms3904 KiB
20Time limit exceeded0/3273ms3824 KiB
21Time limit exceeded0/3284ms3720 KiB
22Time limit exceeded0/3280ms3716 KiB