CodeForces 294A Shaass and Oskols
来源:互联网 发布:最优化理论 推荐教材 编辑:程序博客网 时间:2024/06/07 02:05
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.
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.
On the i-th line of the output print the number of birds on thei-th wire.
510 10 10 10 1052 53 132 121 134 6
0125016
32 4 112 2
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;}
- codeforces 294A Shaass and Oskols
- CodeForces 294A Shaass and Oskols
- codeforces A. Shaass and Oskols 题解
- A. Shaass and Oskols
- Codeforces Round #178 (Div. 2)---A. Shaass and Oskols
- Codeforces Round #178 (Div. 2) / 294A Shaass and Oskols(模拟)
- codeforces 294B Shaass and Bookshelf
- CodeForces 294C - Shaass and Lights 统计
- 排列组合 Shaass and Lights:CodeForces
- codeforces 294B Shaass and Bookshelf (暴力dp)
- codeforces 294C C. Shaass and Lights(组合数学)
- codeforces 294B B. Shaass and Bookshelf(dp)
- codeforces 294C-Shaass and Lights (组合数学)
- CUIT ACM Personal Training 11.27(FM)E - Shaass and Oskols
- Codeforces Round #178 (Div. 2) B Shaass and Bookshelf
- Codeforces Round #178 (Div. 2) B .Shaass and Bookshelf
- Codeforces Round #294 (Div.2) E Shaass the Great
- 【树形DP】 CodeForces 294E Shaass the Great
- 【运动传感器】Madgwick算法(上)
- 设计模式之建造者模式
- MySQLi基于面向过程的编程
- UVA 1593
- poj2481Cows【树状数组】
- CodeForces 294A Shaass and Oskols
- MySQLi基于面向对象的编程
- UVA 1594
- MySQLi的高级应用
- no system images installed for target 问题的解决办法
- 函数指针 虚函数遐思
- hdoj5489Removed Interval【lis】
- UVA 10935
- neuq oj 1012 SZ斐波拉契数列 C++