14382022-10-02 10:54:16HorakZsofiVölgy (100 pont)cpp11Accepted 100/10043ms6480 KiB
#include <bits/stdc++.h>
using namespace std;
int blabla(vector<int>& volgyek, int n) {
    vector<int>nyilak(n);
    int szaml=0;
    nyilak[n-1]=-1;
    for(int i=n-2; i>=0; i--){
        nyilak[i]=i+1;
        while(nyilak[i]!=-1 && volgyek[nyilak[i]]<volgyek[i]){
            nyilak[i]=nyilak[nyilak[i]];
        }
        szaml=max(nyilak[i]-i, szaml);
    }
    return szaml;
}

int main() {
int n;
cin>>n;
vector<int>volgyek(n);
vector<int>hatul(n);
for(int i=0; i<n; i++){
    cin>>volgyek[i];
    hatul[n-i-1]=volgyek[i];
}
int ki=max(blabla(volgyek, n), blabla(hatul, n));
if(ki<2){
    cout<<-1;
}
else{cout<<ki;}

}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1816 KiB
2Accepted0/02ms2064 KiB
3Accepted5/52ms2256 KiB
4Accepted5/52ms2336 KiB
5Accepted5/52ms2588 KiB
6Accepted5/52ms2752 KiB
7Accepted5/52ms2984 KiB
8Accepted5/52ms3112 KiB
9Accepted5/52ms3116 KiB
10Accepted5/52ms3116 KiB
11Accepted5/54ms3416 KiB
12Accepted5/54ms3676 KiB
13Accepted5/54ms3896 KiB
14Accepted5/56ms3844 KiB
15Accepted5/535ms6128 KiB
16Accepted5/537ms6260 KiB
17Accepted5/543ms6428 KiB
18Accepted5/535ms6480 KiB
19Accepted5/535ms6480 KiB
20Accepted5/539ms6256 KiB
21Accepted5/539ms6364 KiB
22Accepted5/539ms6292 KiB