Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. using std::cin;
  7. using std::cout;
  8. using std::vector;
  9. using std::string;
  10.  
  11. void WORRY(vector<bool>& vv, int index) {
  12. vv[index] = false;
  13. }
  14. void QUIET(vector<bool>& vv, int index) {
  15. vv[index] = true;
  16. }
  17. void COME(vector<bool>& vv, int value) {
  18. vv.resize(vv.size() + value, true);
  19. }
  20. int WORRY_COUNT(vector<bool>& vv) {
  21. int result = std::count(begin(vv), end(vv), false);
  22. return result < 0 ? 0 : result;
  23. }
  24.  
  25. int main() {
  26. vector<bool> queue = {};
  27. int n = 0;
  28. cin >> n;
  29. int temp = 0;
  30. string opcode = "";
  31. for (size_t i(0); i < n; i++) {
  32. cin >> opcode;
  33. if (opcode == "COME") {
  34. cin >> temp;
  35. COME(queue, temp);
  36. }
  37. else if (opcode == "QUET") {
  38. cin >> temp;
  39. QUIET(queue, temp);
  40. }
  41. else if (opcode == "WORRY") {
  42. cin >> temp;
  43. WORRY(queue, temp);
  44. }
  45. else if (opcode == "WORRY_COUNT") {
  46. cout << WORRY_COUNT(queue) << std::endl;
  47. }
  48. }
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement