Source Code
#include<iostream>
using namespace std;
int main()
{
	int n, x[100001], tmp, co = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	tmp = x[0];
	for (int i = 0; i < n-1; i++)
	{
		if (tmp == x[i + 1])
			continue;
		co++;
		if (i + 2 < n)
			tmp = x[i + 2];
	}
	cout << co;
	return 0;
}
Copy
Tha Bits master2000
GNU G++17
26 ms
696 KB
Accepted