16362022-11-30 19:17:11bzsofiaSíkság (55)cpp11Time limit exceeded 28/55277ms4736 KiB
#include <iostream>
#include <vector>

using namespace std;

long long i, n, j, maxtav, maxi, minsz, maxsz;

int main()
{
    cin>>n;

    vector <long long> x(n+1);

    for (i=1; i<=n; ++i) cin>>x[i];

    for (i=1; i<n; ++i)
    {
        maxsz=x[i];
        minsz=x[i];
        for (j=i+1; j<=n; ++j)
        {
            if (x[j]>maxsz) maxsz=x[j];
            if (x[j]<minsz) minsz=x[j];
            if (maxsz-minsz>1) break;
            else if (j-i+1>maxtav)
            {
                maxtav=j-i+1;
                maxi=i;
            }
        }
    }

    if (maxtav==0) cout<<"1 1";
    else cout<<maxtav<<" "<<maxi;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/55
1Accepted0/03ms1684 KiB
2Accepted0/020ms2048 KiB
3Accepted2/22ms2052 KiB
4Accepted2/22ms2256 KiB
5Accepted2/22ms2456 KiB
6Accepted2/22ms2668 KiB
7Accepted3/32ms2740 KiB
8Accepted2/23ms2996 KiB
9Accepted3/33ms2988 KiB
10Accepted3/319ms3336 KiB
11Accepted3/34ms3244 KiB
12Accepted3/3148ms3080 KiB
13Accepted3/335ms4492 KiB
14Time limit exceeded0/3268ms3388 KiB
15Time limit exceeded0/3266ms3540 KiB
16Time limit exceeded0/3266ms3688 KiB
17Time limit exceeded0/3216ms3776 KiB
18Time limit exceeded0/3270ms3824 KiB
19Time limit exceeded0/3277ms4092 KiB
20Time limit exceeded0/3273ms4096 KiB
21Time limit exceeded0/3216ms4736 KiB
22Time limit exceeded0/3261ms3920 KiB