38912023-03-03 18:10:35Erik_GepardSíkság (55)cpp17Accepted 55/5532ms7808 KiB
#include<bits/stdc++.h>
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int &x : a) cin>>x;
    int j=0;
    multiset<int> num;
    int maxi=0, bigi=0;
    num.insert(a[0]);
    for(int i=0; i<n && j<n; i++){
        while(*num.rbegin()-*num.begin()<=1 && j<n){
            j++;
            num.insert(a[j]);
        }
        //cerr<<num.size()-1<<" "<<maxi<<"\n";
        if(maxi<num.size()-1){
            maxi=num.size()-1;
            bigi=i+1;
        }
        num.erase(num.find(a[i]));
    }
    cout<<maxi<<" "<<bigi<<"\n";
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms1828 KiB
2Accepted0/04ms2512 KiB
3Accepted2/23ms2264 KiB
4Accepted2/23ms2456 KiB
5Accepted2/23ms2652 KiB
6Accepted2/23ms2788 KiB
7Accepted3/33ms2984 KiB
8Accepted2/23ms3104 KiB
9Accepted3/33ms3348 KiB
10Accepted3/34ms3356 KiB
11Accepted3/34ms3320 KiB
12Accepted3/34ms4424 KiB
13Accepted3/320ms4168 KiB
14Accepted3/332ms7808 KiB
15Accepted3/329ms6636 KiB
16Accepted3/328ms4904 KiB
17Accepted3/330ms7112 KiB
18Accepted3/326ms6540 KiB
19Accepted3/328ms7100 KiB
20Accepted3/328ms6640 KiB
21Accepted3/314ms5520 KiB
22Accepted3/325ms7060 KiB