68632023-12-19 12:49:34madvirSíkság (55)cpp17Wrong answer 34/5535ms5260 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) {
            if(a[x-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--;
                hossz++;
            }
            if(hossz>maxs) {
                maxs=hossz;
                k=x+1;
            }
        }
        else {
            if(a[x]==a[x-1]) {
                hossz=0;
                e=a[x];
                while(a[x]==a[x-1]) {
                    x--;
                    hossz++;
                }
                m=a[x];
                if((e-m)*(e-m)==1) {
                    while(a[x]==e || a[x]==m) {
                        x--;
                        hossz++;
                    }
                }
                if(hossz>maxs) {
                    maxs=hossz;
                    k=k+1;
                }
            }
            else {
                x--;
            }
        }
    }

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


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base34/55
1Accepted0/03ms1880 KiB
2Accepted0/04ms2280 KiB
3Wrong answer0/23ms2448 KiB
4Wrong answer0/23ms2968 KiB
5Wrong answer0/23ms2920 KiB
6Accepted2/23ms2996 KiB
7Wrong answer0/33ms2924 KiB
8Accepted2/23ms3036 KiB
9Accepted3/33ms3096 KiB
10Accepted3/36ms3240 KiB
11Accepted3/34ms3324 KiB
12Accepted3/34ms3452 KiB
13Accepted3/334ms4408 KiB
14Accepted3/320ms4616 KiB
15Accepted3/327ms4856 KiB
16Wrong answer0/335ms4936 KiB
17Wrong answer0/335ms5184 KiB
18Wrong answer0/335ms5168 KiB
19Accepted3/335ms5260 KiB
20Accepted3/335ms5144 KiB
21Accepted3/318ms4696 KiB
22Wrong answer0/328ms4932 KiB