Source Code
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <iterator>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <fstream>
#include <functional>
#include <iomanip>
#include <cctype>
#include <utility>
#include <bitset>
#include <tuple>
#include <sstream>
#include <math.h>

using namespace std;
#define ll long long
#define lll long long int
#define PI 3.1415926535897
#define ld long double
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(X) ((ll)(X).size())
#define pll pair<ll, ll>
#define pi pair<int, int>
#define pb push_back
#define in insert
#define al(it) it.fr << " " << it.sc << "\n"
#define _cout(v)  for(auto f : v ) cout << f << " " ;
#define _cin(v)   for(auto &it : v)cin >> it ;
int main()
{   
	ll n; cin >> n;
	vector<ll>v(n);
	_cin(v);
	ll s = 0;
	for (int i = 0; i < n - 1; i++) {
		if (v[i] != v[i + 1]) {
			s++;
			i++;
		}
	}
	cout << s;
	return 0;
}
Copy
Tha Bits Ayman_Attili
GNU G++17
26 ms
1.1 MB
Accepted