27262023-01-19 13:46:34DalmVölgy (100 pont)cpp11Runtime error 25/10037ms5376 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=-2;
  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==1);
        return -1;
    }
    if(v-k>maxhossz)
        maxhossz=v-k;
        k=v-1;
    }
    cout<<maxhossz;

return 0;
}
SubtaskSumTestVerdictTimeMemory
base25/100
1Runtime error0/03ms1872 KiB
2Runtime error0/02ms1960 KiB
3Accepted5/52ms2168 KiB
4Accepted5/52ms2376 KiB
5Runtime error0/52ms2568 KiB
6Runtime error0/52ms2648 KiB
7Wrong answer0/52ms2648 KiB
8Runtime error0/52ms2912 KiB
9Runtime error0/52ms2968 KiB
10Runtime error0/52ms2928 KiB
11Runtime error0/54ms3336 KiB
12Runtime error0/54ms3620 KiB
13Runtime error0/54ms3632 KiB
14Runtime error0/56ms3764 KiB
15Runtime error0/529ms4572 KiB
16Runtime error0/534ms4580 KiB
17Runtime error0/534ms4836 KiB
18Accepted5/534ms4932 KiB
19Runtime error0/534ms4908 KiB
20Accepted5/537ms5052 KiB
21Runtime error0/537ms5240 KiB
22Accepted5/537ms5376 KiB