27272023-01-19 14:03:18KristófVölgy (100 pont)cpp11Time limit exceeded 85/100259ms4700 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;

    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/03ms1872 KiB
2Accepted0/02ms2120 KiB
3Accepted5/52ms2372 KiB
4Accepted5/52ms2480 KiB
5Accepted5/52ms2688 KiB
6Accepted5/52ms2760 KiB
7Accepted5/52ms2764 KiB
8Accepted5/52ms2888 KiB
9Accepted5/54ms2960 KiB
10Accepted5/52ms2996 KiB
11Accepted5/54ms3220 KiB
12Accepted5/54ms3452 KiB
13Accepted5/54ms3528 KiB
14Accepted5/56ms3532 KiB
15Accepted5/530ms4396 KiB
16Accepted5/534ms4448 KiB
17Time limit exceeded0/5259ms3276 KiB
18Accepted5/534ms4444 KiB
19Time limit exceeded0/5238ms3216 KiB
20Accepted5/537ms4448 KiB
21Time limit exceeded0/5259ms3336 KiB
22Accepted5/537ms4700 KiB