#include #include #include #include struct pillow { int x, y, s; }; int main(int argc, char *argv[]) { std::ifstream in(argv[1]); if (!in.is_open()) { std::cout << "Error opening file" << std::endl; return 1; } int N, V, S; in >> N >> V >> S; std::vector> columns(S); char c; int row; std::vector pillows; pillows.reserve(N); pillow p; int max_fall = 0; for (size_t i = 0; i < N; i++) { in >> c; if (c == '+') { in >> p.x >> p.y >> p.s; p.s--; pillows.push_back(p); for (int j = p.y; j <= p.y + p.s; j++) { columns[j].insert(p.x); } } else { in >> row; pillow p = pillows[row - 1]; for (int j = p.y; j <= p.y + p.s; j++) { columns[j].erase(columns[j].find(p.x)); } } for (auto &i : columns) { auto it = i.begin(); if (it == i.end()) { max_fall = V; break; } else { if (*it > max_fall) max_fall = *it; } } std::cout << max_fall << std::endl; max_fall = 0; } return 0; }