90862024-02-13 19:57:35RRoliSíkság (55)cpp17Runtime error 0/5537ms9040 KiB
#include <bits/stdc++.h>

using namespace std;

int n, a[100001], sz[100001], maxi_l = 1, maxi_r = 1;
set<int> van;

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

    int l = 1;
	van.insert(a[1]);
    sz[a[1]]++;

    for(int r = 2; r <= n; r++) {
        sz[a[r]]++;
		van.insert(a[r]);
		for(int i : van) {
			if(abs(a[r] - i) > 1) {
				while(sz[i] != 0) {
					l++;
					sz[a[l-1]]--;
				}
				van.erase(i);
			}
		}
		if(r-l > maxi_r-maxi_l) {maxi_r = r; maxi_l = l;}
    }

	cout << maxi_l << ' ' << maxi_r;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Runtime error0/03ms1980 KiB
2Runtime error0/04ms2348 KiB
3Runtime error0/23ms2420 KiB
4Runtime error0/23ms2828 KiB
5Runtime error0/23ms2856 KiB
6Runtime error0/23ms2888 KiB
7Runtime error0/33ms2976 KiB
8Runtime error0/23ms3092 KiB
9Runtime error0/33ms3244 KiB
10Runtime error0/36ms3420 KiB
11Runtime error0/34ms3680 KiB
12Wrong answer0/34ms3808 KiB
13Runtime error0/334ms4908 KiB
14Runtime error0/320ms5176 KiB
15Runtime error0/328ms5712 KiB
16Runtime error0/335ms6232 KiB
17Runtime error0/337ms6820 KiB
18Runtime error0/335ms7576 KiB
19Runtime error0/335ms7908 KiB
20Runtime error0/335ms8472 KiB
21Runtime error0/318ms8480 KiB
22Runtime error0/328ms9040 KiB