Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int n;
- std::cin>>n;
- bool t = false;
- int cnt = 0;
- for(int i = 0 ; i != n ;++i)
- {
- int temp;
- std::cin>>temp;
- if(temp == 2 && t == false)
- {
- cnt++;
- }
- if(temp == 2 && t == true)
- {
- t = false;
- }
- if(temp == 1)
- {
- t = true;
- }
- //std::cout<<temp<<t<<cnt<<std::endl;
- }
- std::cout<<cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement