145872025-01-19 14:34:44miszorimarciÉrdekes túra (70 pont)cpp17Wrong answer 67/7028ms756 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
	vector<int>H(n);
	for(int &i : H)cin >> i;
	bool b = false;
	int cnt = 0, max_length = -1, current_length = 0;
	for(int i = 1; i < n; i++)
	{
		if(H[i] != H[i-1] && b)
		{
			current_length++;
			max_length = max(current_length, max_length);
			
		}
		if(H[i] != H[i-1] && !b)
		{
			current_length = 2;
			cnt++;
			b = true;
			max_length = max(current_length, max_length);
		}
		if(H[i] == H[i-1] && b)b = false;
	}
	if(max_length == -1)
	{
		cout << -1;
		return 0;
	}
	cout << cnt << "\n" << max_length;
}
SubtaskSumTestVerdictTimeMemory
base67/70
1Accepted0/01ms316 KiB
2Accepted0/024ms756 KiB
3Accepted3/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms508 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms508 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Accepted3/32ms316 KiB
13Accepted4/42ms348 KiB
14Accepted4/414ms600 KiB
15Accepted4/417ms568 KiB
16Accepted4/417ms640 KiB
17Accepted4/418ms652 KiB
18Accepted4/418ms564 KiB
19Accepted4/426ms564 KiB
20Accepted4/424ms620 KiB
21Accepted4/428ms564 KiB
22Accepted4/420ms564 KiB