27282023-01-19 14:04:53KristófVölgy (100 pont)cpp11Time limit exceeded 85/100300ms5132 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int magassag[n];
    for(int i=0; i<n; i++)
        cin>>magassag[i];

    int k, v;
    if(n==1||n==2){
        cout<<-1;
        return 0;
    }

    int maxhossz=-1;
    int masodik = 0; //második legnagyobb indexe

    for(k=0; k<=n-3; k++){
        v=k+1;
        masodik=k+1;
        while(magassag[v]<magassag[k] && v!=n){
            if (magassag[v]>magassag[masodik])
                masodik=v;
            v++;

        }
        if(v==n){
            v=masodik;
        }

        if(v-k>maxhossz)
            maxhossz=v-k;

        k=v-1;
    }
if(maxhossz<2){
    cout<<-1;
    return 0;
}
    cout<<maxhossz;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base85/100
1Accepted0/03ms1748 KiB
2Accepted0/02ms1916 KiB
3Accepted5/52ms2116 KiB
4Accepted5/52ms2188 KiB
5Accepted5/52ms2188 KiB
6Accepted5/52ms2444 KiB
7Accepted5/52ms2644 KiB
8Accepted5/52ms2848 KiB
9Accepted5/54ms2928 KiB
10Accepted5/52ms3156 KiB
11Accepted5/54ms3096 KiB
12Accepted5/54ms3240 KiB
13Accepted5/54ms3320 KiB
14Accepted5/56ms3444 KiB
15Accepted5/530ms4260 KiB
16Accepted5/534ms4264 KiB
17Time limit exceeded0/5263ms3216 KiB
18Accepted5/534ms4632 KiB
19Time limit exceeded0/5300ms3672 KiB
20Accepted5/537ms4916 KiB
21Time limit exceeded0/5263ms3744 KiB
22Accepted5/537ms5132 KiB