114652024-10-01 08:48:13tKriszSíkság (55)cpp17Accepted 55/5534ms1000 KiB
#include <iostream>

using namespace std;

struct focus{
    int index=1;
    int length=1;
};

int main()
{
    int n, t, ert;
    focus e0, e2, maxi;
    cin>>n;
    cin>>t;
    ert=t;
    for(int i=2;i<=n;i++){
        cin>>t;
        if(ert-t==0){
            e0.length++;
            e2.length++;
            if(e2.length>maxi.length){
                maxi.index=e2.index;
                maxi.length=e2.length;
            }
            if(e0.length>maxi.length){
                maxi.index=e0.index;
                maxi.length=e0.length;
            }
            continue;
        }
        if(ert-t==1){
            swap(e0, e2);
            e0.length=1;
            e0.index=i;
            e2.length++;
            ert=t;
            if(e2.length>maxi.length){
                maxi.index=e2.index;
                maxi.length=e2.length;
            }
            continue;
        }
        if(ert-t==-1){
            swap(e0, e2);
            e2.length=1;
            e2.index=i;
            e0.length++;
            ert=t;
            if(e0.length>maxi.length){
                maxi.index=e0.index;
                maxi.length=e0.length;
            }
            continue;
        }
        ert=t;
        e0.length=1;
        e2.length=1;
        e0.index=i;
        e2.index=i;

    }
    cout<<maxi.length<<' '<<maxi.index;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms360 KiB
2Accepted0/04ms556 KiB
3Accepted2/23ms504 KiB
4Accepted2/23ms488 KiB
5Accepted2/23ms360 KiB
6Accepted2/23ms360 KiB
7Accepted3/33ms504 KiB
8Accepted2/23ms376 KiB
9Accepted3/33ms360 KiB
10Accepted3/36ms360 KiB
11Accepted3/34ms360 KiB
12Accepted3/34ms632 KiB
13Accepted3/332ms916 KiB
14Accepted3/318ms632 KiB
15Accepted3/326ms768 KiB
16Accepted3/332ms828 KiB
17Accepted3/334ms872 KiB
18Accepted3/334ms1000 KiB
19Accepted3/334ms1000 KiB
20Accepted3/334ms908 KiB
21Accepted3/317ms540 KiB
22Accepted3/327ms964 KiB