132772025-01-07 11:51:05MezeiDavidVölgy (100 pont)cpp17Accepted 100/10039ms1588 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/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted5/51ms508 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms332 KiB
6Accepted5/51ms316 KiB
7Accepted5/51ms316 KiB
8Accepted5/51ms316 KiB
9Accepted5/51ms316 KiB
10Accepted5/51ms408 KiB
11Accepted5/53ms316 KiB
12Accepted5/53ms316 KiB
13Accepted5/54ms476 KiB
14Accepted5/54ms508 KiB
15Accepted5/535ms1588 KiB
16Accepted5/537ms1576 KiB
17Accepted5/535ms1452 KiB
18Accepted5/535ms1568 KiB
19Accepted5/535ms1568 KiB
20Accepted5/539ms1452 KiB
21Accepted5/539ms1576 KiB
22Accepted5/539ms1576 KiB