daily pastebin goal
86%
SHARE
TWEET

Untitled

daniv1 Feb 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top