57542023-09-16 13:31:28AblablablaSíkság (55)cpp17Accepted 55/5535ms9452 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> eredeti(n, 0);
    for(int i = 0; i < n; i++){
        cin >> eredeti[i];
    }

    int maxi = 0;
    int maxInd = 0;
    int utolsoH = 0;
    int utolso = -2;
    int akt = 0;
    int masik = -2;

    for(int i = 0; i < n; i++){
        if(utolso == eredeti[i]){
            utolsoH++;
            akt++;
        } else{
            if(abs(utolso - eredeti[i]) <= 1){
                if(masik == eredeti[i]){
                    masik = utolso;
                    akt++;
                } else{
                    masik = utolso;
                    akt = utolsoH + 1;
                }
                utolso = eredeti[i];
                utolsoH = 1;

            } else{
                utolso = eredeti[i];
                utolsoH = 1;
                akt = 1;
            }
        }

        if(akt > maxi){
            maxi = akt;
            maxInd = i;
        }
    }

    cout << maxi << " " << maxInd + 2 - maxi << "\n";
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms1812 KiB
2Accepted0/04ms2176 KiB
3Accepted2/23ms2260 KiB
4Accepted2/23ms2500 KiB
5Accepted2/23ms2724 KiB
6Accepted2/23ms2852 KiB
7Accepted3/33ms2880 KiB
8Accepted2/23ms2888 KiB
9Accepted3/33ms3136 KiB
10Accepted3/36ms3284 KiB
11Accepted3/34ms3516 KiB
12Accepted3/34ms3772 KiB
13Accepted3/332ms4948 KiB
14Accepted3/319ms5356 KiB
15Accepted3/327ms5780 KiB
16Accepted3/334ms6284 KiB
17Accepted3/335ms7104 KiB
18Accepted3/335ms7648 KiB
19Accepted3/335ms8224 KiB
20Accepted3/335ms8792 KiB
21Accepted3/318ms8636 KiB
22Accepted3/328ms9452 KiB