69632023-12-22 00:02:18999Völgy (100 pont)cpp17Wrong answer 85/10037ms4524 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++;
			}
			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/03ms2064 KiB
3Accepted5/53ms2240 KiB
4Accepted5/53ms2328 KiB
5Accepted5/53ms2528 KiB
6Accepted5/53ms2744 KiB
7Accepted5/53ms2824 KiB
8Accepted5/53ms2820 KiB
9Wrong answer0/53ms2828 KiB
10Accepted5/53ms2960 KiB
11Accepted5/54ms3080 KiB
12Accepted5/54ms3356 KiB
13Accepted5/56ms3284 KiB
14Wrong answer0/56ms3368 KiB
15Accepted5/532ms4228 KiB
16Accepted5/535ms4348 KiB
17Wrong answer0/534ms4312 KiB
18Accepted5/535ms4312 KiB
19Accepted5/535ms4316 KiB
20Accepted5/537ms4380 KiB
21Accepted5/537ms4524 KiB
22Accepted5/537ms4380 KiB