29232023-02-04 14:32:51horvathabelSíkság (55)cpp17Wrong answer 26/5535ms4324 KiB

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

int main() {
	int n;
	cin>>n;
	bool vane[n];
	int x;
	cin>>x;
	int mx=x, mn=x;
	int ans=1;  
	int mego=-1;
	int lk=-1;
	int k=1; 
	for (int i=1; i<n;i++){
		int y; 
		cin>>y; 
		if (mx==mn){
			if (y==mx ) ans++;

			else if (y==mx+1){
				ans++;
				mx=y;
			}
			else if (y==mn-1){
				ans++;
				mn=y;
			}
			else{
				mn=y; 
				mx=y; 
				k=i+1; 
				ans=1;
			}

		}
		else{
			if (mn==y or mx==y) ans++;
			else{
				if (ans>mego){
					mego=ans; 
					lk=k;
				} 
				mn=y; 
				mx=y; 
				ans=1; 
				k=i+1;
			}
		}
	}
	if (ans>mego){
		cout<<ans<<" "<<k;
		return 0;
	}
	cout<<mego<<" "<<lk; 
}
SubtaskSumTestVerdictTimeMemory
base26/55
1Accepted0/03ms1872 KiB
2Wrong answer0/04ms2120 KiB
3Accepted2/23ms2276 KiB
4Accepted2/23ms2636 KiB
5Wrong answer0/22ms2708 KiB
6Accepted2/23ms2860 KiB
7Wrong answer0/33ms3060 KiB
8Accepted2/23ms3276 KiB
9Accepted3/33ms3516 KiB
10Wrong answer0/34ms3496 KiB
11Wrong answer0/34ms3460 KiB
12Accepted3/34ms3584 KiB
13Wrong answer0/332ms3668 KiB
14Wrong answer0/318ms3916 KiB
15Wrong answer0/326ms4000 KiB
16Accepted3/332ms3884 KiB
17Wrong answer0/334ms4120 KiB
18Wrong answer0/335ms4208 KiB
19Accepted3/334ms4320 KiB
20Accepted3/334ms4324 KiB
21Accepted3/318ms4272 KiB
22Wrong answer0/327ms4276 KiB