29222023-02-04 14:29:38horvathabelSíkság (55)cpp17Wrong answer 21/5535ms4284 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;
			}
		}
	}
	cout<<mego<<" "<<lk; 
}
SubtaskSumTestVerdictTimeMemory
base21/55
1Accepted0/03ms2152 KiB
2Wrong answer0/04ms2204 KiB
3Wrong answer0/23ms2408 KiB
4Accepted2/23ms2536 KiB
5Wrong answer0/23ms2748 KiB
6Accepted2/23ms2864 KiB
7Wrong answer0/33ms3140 KiB
8Accepted2/23ms3056 KiB
9Accepted3/33ms3200 KiB
10Wrong answer0/36ms3240 KiB
11Wrong answer0/34ms3492 KiB
12Wrong answer0/34ms3664 KiB
13Wrong answer0/332ms3752 KiB
14Wrong answer0/318ms3752 KiB
15Wrong answer0/327ms3752 KiB
16Accepted3/334ms3884 KiB
17Wrong answer0/335ms3964 KiB
18Wrong answer0/335ms4092 KiB
19Accepted3/335ms4176 KiB
20Accepted3/335ms4284 KiB
21Accepted3/318ms4240 KiB
22Wrong answer0/328ms4240 KiB