School Renovation

Company: Capital One

Difficulty: easy

Problem Statement

School Renovation A school is being renovated. It currently has `N` classrooms arranged in a single row and numbered `1` to `N` from left to right. The `i`-th classroom has a capacity of `A[i]` students. Bob is a builder standing inside classroom `1`. Alice gives him `Q` instructions, which he carries out one after another in the order given. Each instruction is one of three types: `1 L` -- Bob moves `L` classrooms to the left. `2 R` -- Bob moves `R` classrooms to the right. `3 X Y` -- Bob demolishes the classroom immediately to the right of the one he is standing in, and builds two new classrooms in its place: first one of capacity `X`, then one of capacity `Y`. Both are inserted directly to the right of Bob's classroom, in that order, so the new classroom of capacity `X` becomes Bob's immediate right neighbour and the new classroom of capacity `Y` sits immediately to the right of that one. An instruction of type `3` removes one classroom and adds two, so the row grows by ex