#include #include #include #include #include using namespace std; int main() { int n; string line; getline(cin, line); istringstream stream(line); vector targets; while (stream >> n) { targets.push_back(n); } string command; cin >> command; while (command != "End") { int index, value; cin >> index >> value; if (command == "Shoot") { if (index >= 0 && index < targets.size()) { targets[index] -= value; if (targets[index] <= 0) { targets.erase(targets.begin() + index); } } } else if (command == "Add") { if (index >= 0 && index < targets.size()) { targets.insert(targets.begin() + index, value); } else { cout << "Invalid placement!\n"; } } else if (command == "Strike") { if (index - value >= 0 && index + value < targets.size()) { targets.erase(targets.begin() + index - value, targets.begin() + value + index + 1); } else { cout << "Strike missed!\n"; } } cin >> command; } for (int i = 0; i < targets.size(); i++) { cout << targets[i] << (i < targets.size() - 1 ? "|" : ""); } return 0; }