68782023-12-19 13:29:29madvirSíkság (55)cpp17Time limit exceeded 8/55300ms4748 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n+1], maxs=0, hossz=0, k, e, m, x;
    for(int i=1; i<=n; i++) {
        cin >> a[i];
    }
    x=n;

    while(x>1) {
        if((a[x]-a[x-1])*(a[x]-a[x-1])==1) {
            hossz=0;
            e=a[x];
            m=a[x-1];
            if(x<n) {
                if(a[x+1]==e || a[x+1]==m) {
                    while((a[x+1]==e || a[x+1]==m) && x<n) {
                        x++;
                    }
                }
            }
            while((a[x]==e || a[x]==m) && x>=1) {
                x--;
                hossz++;
            }
            if(hossz>=maxs) {
                maxs=hossz;
                k=x+1;
            }
            x++;
        }
        else {
            if(a[x]==a[x-1]) {
                hossz=0;
                e=a[x];
                while(a[x]==a[x-1] && x>=1) {
                    x--;
                    hossz++;
                }
                m=a[x];
                if((e-m)*(e-m)==1) {
                    while((a[x]==e || a[x]==m) && x>=1) {
                        x--;
                        hossz++;
                    }
                }
                if(hossz>=maxs) {
                    maxs=hossz;
                    k=k+1;
                }
                x++;
            }
            else {
                x--;
            }
        }
    }

    cout << maxs << " " << k;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/55
1Accepted0/03ms1872 KiB
2Time limit exceeded0/0298ms2076 KiB
3Time limit exceeded0/2266ms1444 KiB
4Accepted2/23ms2364 KiB
5Wrong answer0/23ms2488 KiB
6Time limit exceeded0/2300ms1924 KiB
7Accepted3/33ms2960 KiB
8Time limit exceeded0/2300ms2976 KiB
9Time limit exceeded0/3270ms3096 KiB
10Time limit exceeded0/3266ms3372 KiB
11Time limit exceeded0/3238ms2716 KiB
12Time limit exceeded0/3273ms3668 KiB
13Time limit exceeded0/3270ms3372 KiB
14Accepted3/319ms4748 KiB
15Time limit exceeded0/3277ms3696 KiB
16Time limit exceeded0/3264ms3604 KiB
17Time limit exceeded0/3273ms3728 KiB
18Time limit exceeded0/3300ms3808 KiB
19Time limit exceeded0/3254ms3876 KiB
20Time limit exceeded0/3246ms3856 KiB
21Time limit exceeded0/3280ms3620 KiB
22Time limit exceeded0/3277ms3732 KiB