Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- #include <string>
- using std::cin;
- using std::cout;
- using std::vector;
- using std::string;
- void WORRY(vector<bool>& vv, int index) {
- vv[index] = false;
- }
- void QUIET(vector<bool>& vv, int index) {
- vv[index] = true;
- }
- void COME(vector<bool>& vv, int value) {
- vv.resize(vv.size() + value, true);
- }
- int WORRY_COUNT(vector<bool>& vv) {
- int result = std::count(begin(vv), end(vv), false);
- return result < 0 ? 0 : result;
- }
- int main() {
- vector<bool> queue = {};
- int n = 0;
- cin >> n;
- int temp = 0;
- string opcode = "";
- for (size_t i(0); i < n; i++) {
- cin >> opcode;
- if (opcode == "COME") {
- cin >> temp;
- COME(queue, temp);
- }
- else if (opcode == "QUET") {
- cin >> temp;
- QUIET(queue, temp);
- }
- else if (opcode == "WORRY") {
- cin >> temp;
- WORRY(queue, temp);
- }
- else if (opcode == "WORRY_COUNT") {
- cout << WORRY_COUNT(queue) << std::endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement