78442024-01-11 13:03:27madvirFasor (40)cpp17Wrong answer 0/40131ms18844 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;
}*/

#include <bits/stdc++.h>

using namespace std;

int main(){

    int n; cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++){
        int x; cin >> x; v.push_back(x);
    }

    int i = 0, j = 0, meg = 0, megi = 0;
    multiset<int> s;

    s.insert(v[0]);

    while (i < n && j < n){
        while (*s.rbegin() - *s.begin() <= 1){
            j++;
            s.insert(v[j]);
        }
        if (s.size()-1 > meg){
            meg = s.size()-1; megi = i+1;
        }
        s.erase(s.find(v[i]));
        i++;
    }

    cout << meg << " " <<   megi;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1960 KiB
2Wrong answer0/06ms2320 KiB
3Wrong answer0/23ms2300 KiB
4Wrong answer0/23ms2472 KiB
5Wrong answer0/23ms2652 KiB
6Wrong answer0/22ms2728 KiB
7Wrong answer0/23ms2856 KiB
8Wrong answer0/23ms2988 KiB
9Wrong answer0/26ms3304 KiB
10Wrong answer0/27ms3264 KiB
11Wrong answer0/28ms4152 KiB
12Wrong answer0/24ms3392 KiB
13Wrong answer0/259ms6228 KiB
14Wrong answer0/263ms10008 KiB
15Wrong answer0/2112ms12448 KiB
16Wrong answer0/2118ms9976 KiB
17Wrong answer0/2127ms12580 KiB
18Wrong answer0/2114ms7896 KiB
19Wrong answer0/2118ms14288 KiB
20Wrong answer0/252ms13404 KiB
21Wrong answer0/2131ms18844 KiB
22Wrong answer0/283ms5492 KiB