38902023-03-03 18:09:44Erik_GepardSíkság (55)cpp17Wrong answer 50/5532ms7876 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=1;
    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){
            num.insert(a[j]);
            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
base50/55
1Accepted0/03ms2104 KiB
2Accepted0/04ms2768 KiB
3Wrong answer0/22ms2520 KiB
4Accepted2/22ms2736 KiB
5Accepted2/23ms2788 KiB
6Accepted2/22ms2796 KiB
7Accepted3/33ms3032 KiB
8Accepted2/23ms3056 KiB
9Accepted3/33ms3060 KiB
10Accepted3/34ms3224 KiB
11Accepted3/34ms3172 KiB
12Wrong answer0/34ms4276 KiB
13Accepted3/320ms4288 KiB
14Accepted3/332ms7876 KiB
15Accepted3/329ms6700 KiB
16Accepted3/327ms4972 KiB
17Accepted3/329ms7052 KiB
18Accepted3/326ms6212 KiB
19Accepted3/328ms6528 KiB
20Accepted3/328ms6412 KiB
21Accepted3/314ms5220 KiB
22Accepted3/325ms6540 KiB