27252023-01-19 13:42:43DalmVölgy (100 pont)cpp11Wrong answer 75/100300ms4988 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>maxhossz)
        maxhossz=v-k;
        k=v-1;
    }
    cout<<maxhossz;

return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/100
1Accepted0/03ms1876 KiB
2Accepted0/02ms2068 KiB
3Accepted5/52ms2272 KiB
4Accepted5/52ms2472 KiB
5Accepted5/52ms2680 KiB
6Accepted5/52ms2752 KiB
7Wrong answer0/52ms3012 KiB
8Accepted5/52ms3252 KiB
9Wrong answer0/54ms3456 KiB
10Accepted5/52ms3488 KiB
11Accepted5/54ms3504 KiB
12Accepted5/54ms3520 KiB
13Accepted5/54ms3524 KiB
14Accepted5/56ms3612 KiB
15Accepted5/530ms4428 KiB
16Accepted5/535ms4348 KiB
17Time limit exceeded0/5300ms3228 KiB
18Accepted5/535ms4588 KiB
19Time limit exceeded0/5287ms3616 KiB
20Accepted5/537ms4748 KiB
21Time limit exceeded0/5277ms4752 KiB
22Accepted5/537ms4988 KiB