Save Parrots SOLUTION
Bobby has decided to hunt some Parrots. There are n horizontal branch of trees aligned parallel to each other. Branches are numbered 1 to n from top to bottom. On each branch there are some parrots sitting next to each other. Supposed there are a[i] parrots sitting on the i−th branch.
Sometimes Bobby shots one of the parrot and the parrot dies (suppose that this parrots sat at the i−th branch). Consequently all the parrots on the i−th branch to the left of the dead parrot get scared and jump up on the branch number i − 1, if there exists no upper branch they fly away. Also all the parrots to the right of the dead parrot jump down on branch number i + 1, if there exists no such branch they fly away.
Bobby has shot m parrots. You’re given the initial number of parrots on each branch, tell him how many parrots are sitting on each branch after the shots.
The first line of the input contains an integer N. The next line contains a list of space-separated integers a1, a2, …, an.
The third line contains an integer M. Each of the next M lines contains two integers x[i] and y[i]. The integers mean that for the i-th time Bobby shoot the y[i]-th (from left) parrot on the x[i]-th branch. It’s guaranteed there will be at least y[i] parrot on the x[i]-th branch at that moment.
On the i−th line of the output print the number of parrots on the i−th branch.
10 10 10 10 10
2 4 1