38892023-03-03 18:06:50Erik_GepardSíkság (55)cpp17Wrong answer 20/55300ms5136 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
base20/55
1Accepted0/03ms1824 KiB
2Accepted0/076ms2536 KiB
3Wrong answer0/23ms2404 KiB
4Accepted2/23ms2376 KiB
5Accepted2/23ms2536 KiB
6Accepted2/23ms2760 KiB
7Accepted3/33ms2720 KiB
8Accepted2/28ms2756 KiB
9Accepted3/38ms2864 KiB
10Accepted3/379ms3280 KiB
11Accepted3/350ms3376 KiB
12Wrong answer0/34ms4364 KiB
13Time limit exceeded0/3300ms3064 KiB
14Time limit exceeded0/3275ms4800 KiB
15Time limit exceeded0/3245ms4180 KiB
16Time limit exceeded0/3273ms3524 KiB
17Time limit exceeded0/3232ms4612 KiB
18Time limit exceeded0/3250ms4488 KiB
19Time limit exceeded0/3264ms4696 KiB
20Time limit exceeded0/3256ms4140 KiB
21Time limit exceeded0/3238ms4396 KiB
22Time limit exceeded0/3261ms5136 KiB