Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- int n, cnt=0;
- cin >> n;
- vector <int> a(n);
- for (int i = 0; i<n; i++) {
- cin >> a[i];
- }
- for (int i = 1; i<n-1; i++) {
- if (a[i-1]==a[i] and a[i]==a[i+1]) {
- cnt+=3;
- for (int j=i+2; j<n-1; j++) {
- if (a[j]==a[i+1]) {
- cnt++;
- } else break;
- }
- }
- } cout << cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement