/////////////////////////////////////////////////////////////////////////////////////////////////////// 
作者:stxy-ferryman
声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 
查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/
链接被删请百度:stxy-ferryman
///////////////////////////////////////////////////////////////////////////////////////////////////////

Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered 1 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 are ai oskols sitting on the i-th wire.

Sometimes Shaass shots one of the birds and the bird dies (suppose that this bird sat at the i-th wire). Consequently all the birds on the i-th wire to the left of the dead bird get scared and jump up on the wire number i - 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 number i + 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 integers a1, a2, ..., an,(0 ≤ ai ≤ 100).

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

Output

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

Examples
input
5
10 10 10 10 10
5
2 5
3 13
2 12
1 13
4 6
output
0
12
5
0
16
input
3
2 4 1
1
2 2
output
3
0
3

题意:有个人闲着无聊去打电线上的绿鸭子,而他在打死一只蠢鸭子后,那只鸭子前面的鸭子向左的电线杆上飞,后面的向右飞,如果没了电线杆,它们就飞走了。最后问你每根电线杆上有几只鸭子。

题解:不必多说,模拟即可

代码:

var
a:array[..] of longint;
n,m,x,y,i,j,k:longint;
begin
readln(n);
for i:= to n do
read(a[i]);
readln(m);
for i:= to m do
begin
readln(x,y);
if x> then a[x-]:=a[x-]+y-;
if x<n then a[x+]:=a[x+]+a[x] -y;
a[x]:=;
end;
for i:= to n do
writeln(a[i]);
end.

CodeForces - 294A Shaass and Oskols的更多相关文章

  1. Codeforce 294A - Shaass and Oskols (模拟)

    Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to ...

  2. Codeforces 294D - Shaass and Painter Robot

    294D - Shaass and Painter Robot 思路: 可以用数学归纳法证明一个结论:整个棋盘黑白相间当且仅当边缘黑白相间. 分奇偶讨论又可得出边缘黑色格个数为n+m-2 这样就可以暴 ...

  3. Codeforces 294B Shaass and Bookshelf:dp

    题目链接:http://codeforces.com/problemset/problem/294/B 题意: 有n本书,每本书的厚度为t[i],宽度为w[i] (1<=t[i]<=2, ...

  4. Codeforces K. Shaass and Bookshelf(动态规划三元组贪心)

    题目描述: B. Shaass and Bookshetime limit per test    2 secondsmemory limit per test 256 megabytesinput  ...

  5. Codeforces 294B Shaass and Bookshelf(记忆化搜索)

    题目 记忆化搜索(深搜+记录状态) 感谢JLGG //记忆话搜索 //一本书2中状态,竖着放或者横着放 //初始先都竖着放,然后从左边往右边扫 #include<stdio.h> #inc ...

  6. Codeforces 294E Shaass the Great

    树形DP.由于n只有5000,可以直接枚举边. 枚举边,将树分成两个子树,然后从每个子树中选出一个点分别为u,v,那么答案就是: 子树1中任意两点距离总和+子树2中任意两点距离总和+子树1中任意一点到 ...

  7. CodeForces 294B Shaass and Bookshelf 【规律 & 模拟】或【Dp】

    这道题目的意思就是排两排书,下面这排只能竖着放,上面这排可以平着放,使得宽度最小 根据题意可以得出一个结论,放上这排书的Width 肯定会遵照从小到大的顺序放上去的 Because the total ...

  8. Codeforces Round #178 (Div. 2)

    A. Shaass and Oskols 模拟. B. Shaass and Bookshelf 二分厚度. 对于厚度相同的书本,宽度竖着放显然更优. 宽度只有两种,所以枚举其中一种的个数,另一种的个 ...

  9. OUC_Summer Training_ DIV2_#13 723afternoon

    A - Shaass and Oskols Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

随机推荐

  1. 读Zepto源码之Gesture模块

    Gesture 模块基于 IOS 上的 Gesture 事件的封装,利用 scale 属性,封装出 pinch 系列事件. 读 Zepto 源码系列文章已经放到了github上,欢迎star: rea ...

  2. AngularJS -- Module (模块)

    点击查看AngularJS系列目录 转载请注明出处:http://www.cnblogs.com/leosx/ 什么是AngularJS的模块 我们所说的模块,是你的AngularJS应用程序的一个组 ...

  3. 编码格式简介:ASCII码、ANSI、GBK、GB2312、GB18030和Unicode、UTF-8,BOM头

    编码格式简介:ASCII码.ANSI.GBK.GB2312.GB18030和Unicode.UTF-8,BOM头 二进制: 只有0和1. 十进制.十六进制.八进制: 计算机其实挺笨的,它只认识0101 ...

  4. 关于VisualStudio一运行带中文程序就出错或输出乱码问题的解决

    昨晚纠结了老半天,各种查资料最后终于解决了此问题.今天上午便来编写这篇随笔了!(由于问题已解决,未附上出状况的截图)以下是解决办法: 此问题的原因应是文件的编码问题,选定好出错的文件后,在菜单栏中选择 ...

  5. HTTP库Axios

    前面的话 本文将详细介绍HTTP库Axios 概述 Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中 [安装] 在Vue中使用,最好安装两个模块axios ...

  6. http://codeforces.com/contest/349

    A. Cinema Line time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  7. Button标签自动刷新问题

    在form表单中,button标签在IE浏览器 type类型默认是button ,而在其他浏览器默认是submit. 解决方法1: 设置类型type="button" <bu ...

  8. ubuntu中使用usb-creator制作live usb

    1.实验环境 ubuntu14.04 2.启动usb-creator 2.1 单击桌面左上角的搜索图标,输入usb-creator,然后选择“应用程序"中的”启动盘创建器“ 2.2 终端中输 ...

  9. dom4j之小小工具

    dom4j经常不用,方法忘了又记,故做出读取xml和把document写入xml的小小工具~~~ /** * 读取document和将document对象写入到xml的小工具 * 使用该类必须给出do ...

  10. zabbix部署

    zabbix部署 ----2016年年终总结 二 服务器端安装   yum install zabbix-server 客户端安装 yum install zabbix-agent 配置Server ...