36222023-03-01 11:43:48UnluckYSíkság (55)cpp11Accepted 55/5552ms8376 KiB
#include <bits/stdc++.h>

using namespace std;

int main(){

    int n; cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++){
        int x; cin >> x; v.push_back(x);
    }

    int i = 0, j = 0, meg = 0, megi = 0;
    multiset<int> s;

    s.insert(v[0]);

    while (i < n && j < n){
        while (*s.rbegin() - *s.begin() <= 1){
            j++;
            s.insert(v[j]);
        }
        if (s.size()-1 > meg){
            meg = s.size()-1; megi = i+1;
        }
        s.erase(s.find(v[i]));
        i++;
    }

    cout << meg << " " <<   megi;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms1812 KiB
2Accepted0/06ms2504 KiB
3Accepted2/23ms2264 KiB
4Accepted2/22ms2300 KiB
5Accepted2/23ms2456 KiB
6Accepted2/23ms2504 KiB
7Accepted3/33ms2716 KiB
8Accepted2/23ms3088 KiB
9Accepted3/33ms3196 KiB
10Accepted3/37ms3340 KiB
11Accepted3/36ms3592 KiB
12Accepted3/37ms4604 KiB
13Accepted3/341ms4780 KiB
14Accepted3/343ms8376 KiB
15Accepted3/346ms6952 KiB
16Accepted3/348ms5452 KiB
17Accepted3/352ms7344 KiB
18Accepted3/348ms6720 KiB
19Accepted3/352ms7144 KiB
20Accepted3/350ms6700 KiB
21Accepted3/325ms5668 KiB
22Accepted3/343ms7164 KiB