90892024-02-13 20:05:59RRoliSíkság (55)cpp14Runtime error 3/5535ms4952 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/03ms1984 KiB
2Runtime error0/04ms2212 KiB
3Runtime error0/23ms2272 KiB
4Runtime error0/23ms2536 KiB
5Runtime error0/23ms2752 KiB
6Runtime error0/23ms2652 KiB
7Runtime error0/33ms2912 KiB
8Runtime error0/23ms2872 KiB
9Runtime error0/33ms3128 KiB
10Runtime error0/36ms3420 KiB
11Runtime error0/34ms3504 KiB
12Accepted3/34ms3608 KiB
13Runtime error0/334ms4424 KiB
14Runtime error0/319ms4640 KiB
15Runtime error0/326ms4532 KiB
16Runtime error0/334ms4792 KiB
17Runtime error0/335ms4880 KiB
18Runtime error0/334ms4816 KiB
19Runtime error0/335ms4952 KiB
20Runtime error0/334ms4808 KiB
21Runtime error0/317ms4516 KiB
22Runtime error0/328ms4732 KiB