14362022-10-01 20:23:32tomi7Völgy (100 pont)cpp11Time limit exceeded 60/100282ms3804 KiB
// Source: https://usaco.guide/general/io

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

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int legnagyobb=0;;
	int valasz=-1;
	for(int j=0;j<n-2;j++){
        for(int i=j+2;i<n;i++){
			legnagyobb=max(legnagyobb, a[i-1]);
			if(legnagyobb<min(a[i], a[j])){
                 valasz=max(valasz, i-j);
			}
		}
		legnagyobb=0;
	}
	cout<<valasz<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base60/100
1Accepted0/03ms1844 KiB
2Accepted0/03ms2096 KiB
3Accepted5/52ms2296 KiB
4Accepted5/52ms2536 KiB
5Accepted5/52ms2704 KiB
6Accepted5/52ms2776 KiB
7Accepted5/52ms2780 KiB
8Accepted5/52ms2776 KiB
9Accepted5/53ms3032 KiB
10Accepted5/53ms2988 KiB
11Accepted5/525ms3084 KiB
12Accepted5/587ms3180 KiB
13Accepted5/589ms3300 KiB
14Accepted5/589ms3504 KiB
15Time limit exceeded0/5244ms3268 KiB
16Time limit exceeded0/5246ms3464 KiB
17Time limit exceeded0/5270ms3508 KiB
18Time limit exceeded0/5268ms3628 KiB
19Time limit exceeded0/5261ms3592 KiB
20Time limit exceeded0/5282ms3528 KiB
21Time limit exceeded0/5259ms3628 KiB
22Time limit exceeded0/5246ms3804 KiB