14652022-10-20 00:39:06tomi7Völgy (100 pont)cpp11Wrong answer 5/10037ms11320 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> jobb(n);
	vector<int> bal(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int legnagyobb=0;
    jobb[n-1]=-1;
	bal[0]=-1;
	for(int i=1;i<n;i++){
		for(int j=i-1;1;){
		    if(a[i]>a[j]){
			     if(bal[j]==-1){
				     bal[i]=-1;
					 break;
			     }
			     if(bal[j]!=-1){
				     j=bal[j];
			     }
		    }else{
				bal[i]==j;
				if(i-j>1){
			         legnagyobb=max(i-j, legnagyobb);
				}
				break;
			}
	    }
	}
	for(int i=n-1;i<=0;i--){
		for(int j=i+1;1;){
		    if(a[i]>a[j]){
			     if(jobb[j]==-1){
				     jobb[i]=-1;
					 break;
			     }
			     if(bal[j]!=-1){
				     j=jobb[j];
			     }
		    }else{
				jobb[i]==j;
				if(j-i>1){
			         legnagyobb=max(j-i, legnagyobb);
				}
				break;
			}
	    }
	}
	cout<<legnagyobb<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base5/100
1Wrong answer0/03ms1944 KiB
2Wrong answer0/02ms2080 KiB
3Wrong answer0/52ms2252 KiB
4Accepted5/52ms2404 KiB
5Wrong answer0/52ms2420 KiB
6Wrong answer0/52ms2548 KiB
7Wrong answer0/52ms2628 KiB
8Wrong answer0/52ms2796 KiB
9Wrong answer0/52ms3032 KiB
10Wrong answer0/52ms2944 KiB
11Wrong answer0/54ms3012 KiB
12Wrong answer0/54ms3376 KiB
13Wrong answer0/54ms3516 KiB
14Wrong answer0/56ms3920 KiB
15Wrong answer0/532ms6360 KiB
16Wrong answer0/535ms7048 KiB
17Wrong answer0/535ms7684 KiB
18Wrong answer0/535ms8256 KiB
19Wrong answer0/535ms9076 KiB
20Wrong answer0/537ms9668 KiB
21Wrong answer0/537ms10348 KiB
22Wrong answer0/537ms11320 KiB