208262026-01-09 16:22:16BikficcSíkság (55)cpp17Accepted 55/5552ms2612 KiB
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int>v(n);
    multiset<int> h;
    for (int i=0; i<n; i++)
    {
        cin >> v[i];
    }
    int aktk=0, maxk=0, maxh=0, akth=0;

    for (int i=0; i<n; i++)
    {
        h.insert(v[i]);
        if (*h.rbegin()-*h.begin()<=1)
        {
            akth++;
        }
        else
        {
            if (akth>maxh)
            {
                maxh=akth;
                maxk=aktk;
            }
            while (*h.rbegin()-*h.begin()>1)
            {
                h.erase(h.find(v[aktk]));
                aktk++;
            }
            akth=h.size();
        }
    }
    if (akth>maxh)
    {
        maxh=akth;
        maxk=aktk;
    }
    cout << maxh << " " << maxk+1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/02ms316 KiB
2Accepted0/04ms580 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms508 KiB
7Accepted3/31ms316 KiB
8Accepted2/22ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/34ms436 KiB
11Accepted3/34ms392 KiB
12Accepted3/34ms824 KiB
13Accepted3/339ms820 KiB
14Accepted3/339ms2612 KiB
15Accepted3/343ms1828 KiB
16Accepted3/346ms1064 KiB
17Accepted3/352ms1840 KiB
18Accepted3/348ms1588 KiB
19Accepted3/350ms1836 KiB
20Accepted3/348ms1564 KiB
21Accepted3/324ms1076 KiB
22Accepted3/341ms1836 KiB