Advertisement
Zuneve

dddddddddd

Nov 18th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, cnt=0;
  8. cin >> n;
  9. vector <int> a(n);
  10. for (int i = 0; i<n; i++) {
  11. cin >> a[i];
  12. }
  13. for (int i = 1; i<n-1; i++) {
  14. if (a[i-1]==a[i] and a[i]==a[i+1]) {
  15. cnt+=3;
  16. for (int j=i+2; j<n-1; j++) {
  17. if (a[j]==a[i+1]) {
  18. cnt++;
  19. } else break;
  20. }
  21. }
  22. } cout << cnt;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement