69652023-12-22 00:04:26999Völgy (100 pont)cpp17Wrong answer 95/10039ms4704 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&&maxi-i>=2)
				ans=max(ans,maxi-i);
		}
		else if(j-i>=2){
			ans=max(ans,j-i);
		}
		i=j;
	}
	cout<<ans<<endl;
}
SubtaskSumTestVerdictTimeMemory
base95/100
1Accepted0/03ms1808 KiB
2Accepted0/03ms2060 KiB
3Accepted5/53ms2304 KiB
4Accepted5/53ms2332 KiB
5Accepted5/53ms2460 KiB
6Accepted5/53ms2668 KiB
7Accepted5/53ms2788 KiB
8Accepted5/53ms2992 KiB
9Accepted5/53ms3200 KiB
10Accepted5/53ms3320 KiB
11Accepted5/54ms3460 KiB
12Accepted5/54ms3532 KiB
13Accepted5/56ms3792 KiB
14Wrong answer0/56ms4020 KiB
15Accepted5/532ms4480 KiB
16Accepted5/535ms4704 KiB
17Accepted5/537ms4596 KiB
18Accepted5/535ms4688 KiB
19Accepted5/535ms4596 KiB
20Accepted5/537ms4596 KiB
21Accepted5/539ms4688 KiB
22Accepted5/539ms4592 KiB