212912026-01-12 17:53:26hunzombiSíkság (55)pypy3Runtime error 0/5576ms22960 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i < n; i++) cin >> a[i];

    multiset<int> ms;
    int low = 0;
    int best_i = -1;
    int best = -1;

    for (int high = 0; high < n; high++) {
        ms.insert(a[high]);

        while (*ms.rbegin() - *ms.begin() > 1) {
            ms.erase(ms.find(a[low]));
            low++;
        }

        if (high - low + 1 > best) {
            best = high - low + 1;
            best_i = low + 1;
        }
    }

    cout << best << ' ' << best_i << '\n';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Runtime error0/064ms22776 KiB
2Runtime error0/071ms22748 KiB
3Runtime error0/276ms22708 KiB
4Runtime error0/264ms22756 KiB
5Runtime error0/274ms22720 KiB
6Runtime error0/264ms22760 KiB
7Runtime error0/364ms22756 KiB
8Runtime error0/271ms22760 KiB
9Runtime error0/364ms22760 KiB
10Runtime error0/372ms22620 KiB
11Runtime error0/364ms22832 KiB
12Runtime error0/371ms22760 KiB
13Runtime error0/364ms22756 KiB
14Runtime error0/372ms22756 KiB
15Runtime error0/374ms22664 KiB
16Runtime error0/371ms22760 KiB
17Runtime error0/364ms22760 KiB
18Runtime error0/372ms22604 KiB
19Runtime error0/371ms22684 KiB
20Runtime error0/376ms22764 KiB
21Runtime error0/371ms22960 KiB
22Runtime error0/363ms22812 KiB