78302024-01-11 12:32:12madvirSíkság (55)cpp17Time limit exceeded 22/55300ms4744 KiB
#include <iostream>
#include <set>

using namespace std;

int main() {
	int n, tart, _max=0, kezd;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	multiset<int> megy;
	for(int i=0; i<n; i++) {
		megy.insert(a[i]);
		tart=i+1;
		megy.insert(a[tart]);
		tart++;
		while(*megy.rbegin()-*megy.begin()<=1) {
			megy.insert(a[tart]);
			tart++;
		}
		if(megy.size()-1>_max) {
			_max=megy.size()-1;
			kezd=i+1;
		}
		megy.clear();
	}

	cout << _max << " " << kezd;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/55
1Accepted0/03ms1808 KiB
2Time limit exceeded0/0300ms1604 KiB
3Accepted2/23ms2328 KiB
4Accepted2/23ms2428 KiB
5Accepted2/23ms2640 KiB
6Accepted2/23ms2852 KiB
7Accepted3/33ms3208 KiB
8Accepted2/218ms3184 KiB
9Accepted3/38ms3288 KiB
10Time limit exceeded0/3300ms3420 KiB
11Accepted3/312ms3660 KiB
12Time limit exceeded0/3300ms3348 KiB
13Accepted3/368ms4360 KiB
14Time limit exceeded0/3234ms4520 KiB
15Time limit exceeded0/3257ms3976 KiB
16Time limit exceeded0/3250ms3656 KiB
17Time limit exceeded0/3250ms4744 KiB
18Time limit exceeded0/3273ms4428 KiB
19Time limit exceeded0/3246ms3856 KiB
20Time limit exceeded0/3273ms3968 KiB
21Time limit exceeded0/3257ms4008 KiB
22Time limit exceeded0/3241ms3920 KiB