68792023-12-19 13:32:09madvirSíkság (55)cpp17Wrong answer 39/5535ms5048 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;
            }
            if(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;
                }
            }
            else {
                x--;
            }
        }
    }

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


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base39/55
1Accepted0/03ms1876 KiB
2Accepted0/04ms2288 KiB
3Wrong answer0/23ms2336 KiB
4Accepted2/23ms2544 KiB
5Wrong answer0/23ms2792 KiB
6Accepted2/23ms2952 KiB
7Accepted3/33ms3028 KiB
8Accepted2/23ms3176 KiB
9Accepted3/33ms3156 KiB
10Accepted3/34ms3128 KiB
11Accepted3/34ms3252 KiB
12Accepted3/34ms3596 KiB
13Accepted3/332ms4420 KiB
14Accepted3/319ms4628 KiB
15Accepted3/326ms4708 KiB
16Wrong answer0/332ms4692 KiB
17Wrong answer0/334ms4696 KiB
18Wrong answer0/335ms4820 KiB
19Accepted3/334ms4924 KiB
20Accepted3/334ms5048 KiB
21Accepted3/318ms4756 KiB
22Wrong answer0/327ms4936 KiB