14372022-10-02 10:51:16HorakZsofiVölgy (100 pont)cpp11Wrong answer 85/10039ms5916 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));
cout<<ki;

}
SubtaskSumTestVerdictTimeMemory
base85/100
1Accepted0/03ms1848 KiB
2Accepted0/03ms2008 KiB
3Accepted5/52ms2248 KiB
4Accepted5/52ms2484 KiB
5Accepted5/52ms2656 KiB
6Accepted5/52ms2696 KiB
7Wrong answer0/52ms2716 KiB
8Accepted5/52ms2692 KiB
9Wrong answer0/52ms2696 KiB
10Accepted5/53ms2996 KiB
11Accepted5/54ms2908 KiB
12Accepted5/54ms3036 KiB
13Accepted5/54ms3028 KiB
14Accepted5/56ms3036 KiB
15Accepted5/535ms5320 KiB
16Accepted5/537ms5508 KiB
17Wrong answer0/535ms5584 KiB
18Accepted5/535ms5580 KiB
19Accepted5/535ms5732 KiB
20Accepted5/539ms5788 KiB
21Accepted5/539ms5908 KiB
22Accepted5/539ms5916 KiB