145882025-01-19 14:39:29miszorimarciÉrdekes túra (70 pont)cpp17Accepted 70/7029ms804 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;
	}
	cout << cnt << "\n" << max_length;
}
SubtaskSumTestVerdictTimeMemory
base70/70
1Accepted0/01ms316 KiB
2Accepted0/025ms564 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms336 KiB
8Accepted3/31ms500 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms412 KiB
12Accepted3/32ms316 KiB
13Accepted4/42ms316 KiB
14Accepted4/414ms748 KiB
15Accepted4/417ms616 KiB
16Accepted4/417ms564 KiB
17Accepted4/419ms568 KiB
18Accepted4/419ms748 KiB
19Accepted4/427ms564 KiB
20Accepted4/425ms564 KiB
21Accepted4/429ms804 KiB
22Accepted4/423ms564 KiB