69642023-12-22 00:03:33999Völgy (100 pont)cpp17Wrong answer 85/10037ms5300 KiB
// Source: https://usaco.guide/general/io

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

int main() {
	int n;cin>>n;
	vector<int> v(n+1);
	for(int i = 1;i<=n;i++)
		cin>>v[i];
	int i=1,ans=-1;
	while(i<=n-2){
		int j=i+1;
		while(j<=n&&v[j]<v[i]){
			j++;
		}
		if(j-i>=2&&j==n+1){
			j=i+1;int mx=0,maxi=0;
			while(j<=n){
				if(mx<v[j]){
					mx=v[j];
					maxi=j;
				}
				j++;
			}
			if(maxi>0)
				ans=max(ans,maxi-i);
		}
		else if(j-i>=2){
			ans=max(ans,j-i);
		}
		i=j;
	}
	cout<<ans<<endl;
}
SubtaskSumTestVerdictTimeMemory
base85/100
1Accepted0/03ms1812 KiB
2Accepted0/03ms2060 KiB
3Accepted5/53ms2296 KiB
4Accepted5/53ms2512 KiB
5Accepted5/53ms2724 KiB
6Accepted5/53ms2936 KiB
7Accepted5/53ms3148 KiB
8Accepted5/53ms3380 KiB
9Wrong answer0/53ms3504 KiB
10Accepted5/53ms3652 KiB
11Accepted5/54ms3880 KiB
12Accepted5/54ms3996 KiB
13Accepted5/56ms4240 KiB
14Wrong answer0/56ms4464 KiB
15Accepted5/530ms5292 KiB
16Accepted5/534ms5036 KiB
17Wrong answer0/535ms5268 KiB
18Accepted5/534ms5036 KiB
19Accepted5/534ms5164 KiB
20Accepted5/537ms5284 KiB
21Accepted5/537ms5300 KiB
22Accepted5/537ms5296 KiB