Save Parrots SOLUTION CODSTAN2

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.

Input:

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.

Output:

On the i−th line of the output print the number of parrots on the i−th branch.

Constraints

1≤N≤100

0≤a[i]≤100

0≤M≤100

1≤x[i]≤n, 1≤y[i]

Sample Input:

5

10 10 10 10 10

5

2 5

3 13

2 12

1 13

4 6

3

2 4 1

1

2 2

Sample Output:

0

12

5

0

16

3

0

3

Related :

Leave a Comment