67682023-12-19 08:19:06Attila27Síkság (55)cpp17Time limit exceeded 25/55300ms4652 KiB
#include <iostream>

using namespace std;

int main()
{
    int n,a[100001],r,db,j,max=0,t;
    bool lehet;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for (int i=1;i<=n;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
base25/55
1Accepted0/03ms2648 KiB
2Accepted0/023ms2888 KiB
3Accepted2/23ms3120 KiB
4Accepted2/23ms3332 KiB
5Accepted2/23ms3480 KiB
6Accepted2/23ms3684 KiB
7Accepted3/33ms3928 KiB
8Accepted2/23ms4012 KiB
9Accepted3/33ms4140 KiB
10Accepted3/319ms4192 KiB
11Accepted3/36ms4436 KiB
12Time limit exceeded0/3236ms4536 KiB
13Accepted3/335ms4652 KiB
14Time limit exceeded0/3300ms3844 KiB
15Time limit exceeded0/3266ms3828 KiB
16Time limit exceeded0/3273ms3828 KiB
17Time limit exceeded0/3273ms3764 KiB
18Time limit exceeded0/3270ms3888 KiB
19Time limit exceeded0/3270ms3904 KiB
20Time limit exceeded0/3273ms4080 KiB
21Time limit exceeded0/3257ms4212 KiB
22Time limit exceeded0/3277ms4208 KiB