90882024-02-13 20:00:46RRoliSíkság (55)cpp17Runtime error 3/5535ms4316 KiB
#include <iostream>
#include <set>

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_r-maxi_l+1 << ' ' << maxi_l;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base3/55
1Runtime error0/03ms1860 KiB
2Runtime error0/04ms2056 KiB
3Runtime error0/23ms2356 KiB
4Runtime error0/23ms2452 KiB
5Runtime error0/23ms2540 KiB
6Runtime error0/23ms2528 KiB
7Runtime error0/33ms2856 KiB
8Runtime error0/23ms3112 KiB
9Runtime error0/33ms3128 KiB
10Runtime error0/36ms3336 KiB
11Runtime error0/34ms3144 KiB
12Accepted3/34ms3432 KiB
13Runtime error0/332ms4076 KiB
14Runtime error0/319ms4080 KiB
15Runtime error0/326ms3952 KiB
16Runtime error0/334ms4088 KiB
17Runtime error0/335ms4024 KiB
18Runtime error0/334ms4300 KiB
19Runtime error0/334ms4232 KiB
20Runtime error0/334ms4316 KiB
21Runtime error0/317ms3996 KiB
22Runtime error0/328ms4236 KiB