Advertisement
daniv1

Untitled

Feb 23rd, 2019
147
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.  
  3. int main()
  4. {
  5. int n;
  6. std::cin>>n;
  7. bool t = false;
  8. int cnt = 0;
  9. for(int i = 0 ; i != n ;++i)
  10. {
  11.  
  12. int temp;
  13. std::cin>>temp;
  14. if(temp == 2 && t == false)
  15. {
  16. cnt++;
  17. }
  18. if(temp == 2 && t == true)
  19. {
  20. t = false;
  21. }
  22. if(temp == 1)
  23. {
  24. t = true;
  25. }
  26. //std::cout<<temp<<t<<cnt<<std::endl;
  27. }
  28. std::cout<<cnt;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement