233932026-01-21 17:21:44ProgramozoRokaSíkság (55)cpp17Wrong answer 0/5534ms512 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int h=-1, hdb=0, he=0, hee=-1;
	int hossz = 0, mhossz = 0, mhosszi = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> h;
		if (h == he)
		{
			++hdb;
			++hossz;
		}
		else if (h == hee)
		{
			hdb = 1;
			hee = he;
			he = h;
			++hossz;
		}
		else if (h == he + 1 or h == he - 1)
		{
			hossz = hdb + 1;
			hdb = 1;
			hee = he;
			he = h;
		}
		else
		{
			he = h;
			hee = -1;
			hdb = 1;
			hossz = 1;
		}

		if (hossz > mhossz)
		{
			mhossz = hossz;
			mhosszi = i - hossz + 1;
		}
	}
	cout << mhossz << " " << mhosszi;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/01ms512 KiB
2Wrong answer0/03ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/21ms352 KiB
9Wrong answer0/31ms380 KiB
10Wrong answer0/34ms396 KiB
11Wrong answer0/33ms396 KiB
12Wrong answer0/33ms316 KiB
13Wrong answer0/332ms396 KiB
14Wrong answer0/317ms404 KiB
15Wrong answer0/326ms396 KiB
16Wrong answer0/332ms396 KiB
17Wrong answer0/334ms316 KiB
18Wrong answer0/334ms396 KiB
19Wrong answer0/334ms400 KiB
20Wrong answer0/332ms500 KiB
21Wrong answer0/317ms324 KiB
22Wrong answer0/326ms396 KiB