67702023-12-19 08:22:46Attila27Síkság (55)cpp17Time limit exceeded 28/55300ms4644 KiB
#include <iostream>

using namespace std;

int main()
{
    int n,a[100001],r,db,j,max=0,t;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for (int i=1;i<=n-max+1;i++)
    {
        db=1;
        r=a[i];
        j=i;
        while (a[j+1]==r && j<n)
        {
            db++;
            j++;
        }
        if (a[j+1]==r+1)
        {
            while ((a[j+1]==r || a[j+1]==r+1) && j<n)
            {
                db++;
                j++;
            }
        }
        else if (a[j+1]==r-1)
        {
            while ((a[j+1]==r || a[j+1]==r-1) && j<n)
            {
                db++;
                j++;
            }
        }
        if (db>max)
        {
            max=db;
            t=i;
        }
    }
    cout<<max<<" "<<t;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/55
1Accepted0/03ms2648 KiB
2Accepted0/023ms3032 KiB
3Accepted2/23ms3104 KiB
4Accepted2/23ms3196 KiB
5Accepted2/23ms3440 KiB
6Accepted2/23ms3496 KiB
7Accepted3/33ms3732 KiB
8Accepted2/24ms3832 KiB
9Accepted3/33ms4044 KiB
10Accepted3/318ms4276 KiB
11Accepted3/36ms4276 KiB
12Accepted3/34ms4512 KiB
13Accepted3/334ms4644 KiB
14Time limit exceeded0/3300ms3564 KiB
15Time limit exceeded0/3257ms3620 KiB
16Time limit exceeded0/3275ms3584 KiB
17Time limit exceeded0/3266ms3708 KiB
18Time limit exceeded0/3270ms3732 KiB
19Time limit exceeded0/3275ms3760 KiB
20Time limit exceeded0/3261ms3720 KiB
21Time limit exceeded0/3282ms3580 KiB
22Time limit exceeded0/3282ms3700 KiB