Advertisement
Guest User

coursera

a guest
Apr 5th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include<string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int operation;
  9.     int people;
  10.     vector<bool> silent;
  11.     int sum=0;
  12.     cin >> operation;
  13.  
  14.     for (int i = 0; i < operation; i++)
  15.     {
  16.         string check;
  17.         cin >> check;
  18.         if (check=="COME"){
  19.             cin >> people;
  20.             if (people>0)
  21.             {
  22.                 silent.assign(silent.size()+people,false);
  23.             }
  24.             else
  25.             {
  26.                 silent.resize(silent.size() + people);
  27.             }
  28.         }
  29.         else if(check=="WORRY")
  30.         {
  31.             cin >> people;
  32.             silent[people] = true;
  33.         }
  34.         else if (check == "QUIET")
  35.         {
  36.             cin >> people;
  37.             silent[people] = false;
  38.         }
  39.         else if (check == "WORRY_COUNT")
  40.         {
  41.             for (auto k : silent) {
  42.                 if (k==true)
  43.                 {
  44.                     sum++;
  45.                 }
  46.             }
  47.             cout << sum<<endl;
  48.         }
  49.         else
  50.         {
  51.             cout << " " << endl;
  52.         }
  53.     }
  54.  
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement