fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int count=1,n;
  7. int x,y;
  8. cin>>n;
  9. cin>>x;
  10. n-=1;
  11. while(n--)
  12. {
  13. cin>>y;
  14. if(x==y){
  15. continue;
  16. }
  17. else
  18. {
  19. x=y;
  20. count++;
  21. }
  22. }
  23. cout<<count;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 4576KB
stdin
6
1 2 3 3 4 5
stdout
5