CodeForces 294A Shaass and Oskols

来源:互联网 发布:最优化理论 推荐教材 编辑:程序博客网 时间:2024/06/07 02:05
A. Shaass and Oskols
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered1 to n from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delicious kind of birds in Shaass's territory. Supposed there areai oskols sitting on thei-th wire.

Sometimes Shaass shots one of the birds and the bird dies (suppose that this bird sat at thei-th wire). Consequently all the birds on thei-th wire to the left of the dead bird get scared and jump up on the wire numberi - 1, if there exists no upper wire they fly away. Also all the birds to the right of the dead bird jump down on wire numberi + 1, if there exists no such wire they fly away.

Shaass has shot m birds. You're given the initial number of birds on each wire, tell him how many birds are sitting on each wire after the shots.

Input

The first line of the input contains an integer n,(1 ≤ n ≤ 100). The next line contains a list of space-separated integersa1, a2, ..., an,(0 ≤ ai ≤ 100).

The third line contains an integer m, (0 ≤ m ≤ 100). Each of the next m lines contains two integersxi andyi. The integers mean that for thei-th time Shaass shoot the yi-th (from left) bird on thexi-th wire,(1 ≤ xi ≤ n, 1 ≤ yi). It's guaranteed there will be at leastyi birds on thexi-th wire at that moment.

Output

On the i-th line of the output print the number of birds on thei-th wire.

Sample test(s)
Input
510 10 10 10 1052 53 132 121 134 6
Output
0125016
Input
32 4 112 2
Output
303
#include<stdio.h>int main(){int n,m,num[110],a,b;while(~scanf("%d",&n)){for(int i=1;i<=n;i++){scanf("%d",&num[i]);}num[0]=num[n+1]=0;scanf("%d",&m);while(m--){scanf("%d %d",&a,&b);num[a+1]+=(num[a]-b);num[a-1]+=(b-1);num[a]=0;}for(int i=1;i<=n;i++){printf("%d\n",num[i]);}} return 0;}

 
0 0
原创粉丝点击