CodeForces - 294A Shaass and Oskols
///////////////////////////////////////////////////////////////////////////////////////////////////////
作者: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.
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.
On the i-th line of the output print the number of birds on the i-th wire.
5
10 10 10 10 10
5
2 5
3 13
2 12
1 13
4 6
0
12
5
0
16
3
2 4 1
1
2 2
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的更多相关文章
- Codeforce 294A - Shaass and Oskols (模拟)
Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to ...
- Codeforces 294D - Shaass and Painter Robot
294D - Shaass and Painter Robot 思路: 可以用数学归纳法证明一个结论:整个棋盘黑白相间当且仅当边缘黑白相间. 分奇偶讨论又可得出边缘黑色格个数为n+m-2 这样就可以暴 ...
- Codeforces 294B Shaass and Bookshelf:dp
题目链接:http://codeforces.com/problemset/problem/294/B 题意: 有n本书,每本书的厚度为t[i],宽度为w[i] (1<=t[i]<=2, ...
- Codeforces K. Shaass and Bookshelf(动态规划三元组贪心)
题目描述: B. Shaass and Bookshetime limit per test 2 secondsmemory limit per test 256 megabytesinput ...
- Codeforces 294B Shaass and Bookshelf(记忆化搜索)
题目 记忆化搜索(深搜+记录状态) 感谢JLGG //记忆话搜索 //一本书2中状态,竖着放或者横着放 //初始先都竖着放,然后从左边往右边扫 #include<stdio.h> #inc ...
- Codeforces 294E Shaass the Great
树形DP.由于n只有5000,可以直接枚举边. 枚举边,将树分成两个子树,然后从每个子树中选出一个点分别为u,v,那么答案就是: 子树1中任意两点距离总和+子树2中任意两点距离总和+子树1中任意一点到 ...
- CodeForces 294B Shaass and Bookshelf 【规律 & 模拟】或【Dp】
这道题目的意思就是排两排书,下面这排只能竖着放,上面这排可以平着放,使得宽度最小 根据题意可以得出一个结论,放上这排书的Width 肯定会遵照从小到大的顺序放上去的 Because the total ...
- Codeforces Round #178 (Div. 2)
A. Shaass and Oskols 模拟. B. Shaass and Bookshelf 二分厚度. 对于厚度相同的书本,宽度竖着放显然更优. 宽度只有两种,所以枚举其中一种的个数,另一种的个 ...
- OUC_Summer Training_ DIV2_#13 723afternoon
A - Shaass and Oskols Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
随机推荐
- 记录兼容IE8中发现的一些问题
1.new Date().getYear(); chrome下:获取的是1900年之后的年份,如2017年获取的是117 IE8下:获取的是公元年份,如2017获取的是2017 解决方案:使用new ...
- 跨Storyboard调用
在开发中我们会有这种需求从一个故事板跳到另一个故事板 modal UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@ ...
- UI自动化测试(三)对页面中定位到的元素对象做相应操作
前两天分别讲述了UI自动化测试基础以及对页面元素该如何进行定位,这一篇自然就是对定位到的页面元素对象进行相应操作啦. 阅读目录 1.常用操作元素对象的方法 2.鼠标事件操作 3.键盘事件操作 4.We ...
- Python数据分析(二): Numpy技巧 (1/4)
In [1]: import numpy numpy.__version__ Out[1]: '1.13.1' In [2]: import numpy as np
- 概率图论PGM的D-Separation(D分离)
目录[-] 本文大部分来自:http://www.zhujun.me/d-separation-separation-d.html 一.引言 二.三种情况分析 三.总结 四.应用例子 五.参考资料 其 ...
- 一张图理清ASP.NET Core启动流程
1. 引言 对于ASP.NET Core应用程序来说,我们要记住非常重要的一点是:其本质上是一个独立的控制台应用,它并不是必需在IIS内部托管且并不需要IIS来启动运行(而这正是ASP.NET Cor ...
- windows phone 模拟器
window phone 模拟器启动报错 修改Bios设置,我的是yoga pro 2,只修改 即可.启动成功
- java 虚拟机与并发处理几个问题简要(二)
六.两个重要的概念性问题: 1.同步:要保持数据的一致性,就需要一种保证并发进程正确执行顺序的机制.这种机制就是 进程同步(Process Synchronization). 竞争资源的多个进程按着特 ...
- ZOJ2185 简单分块 找规律
初步找大概位置,然后找精确位置,算是简单化的分块吧! #include<cstdio> #include<cstdlib> #include<iostream> u ...
- redis requires Ruby version >= 2.2.2问题
最近在研究redis的集群,redis官方提供了redis-trib.rb工具,但是在使用之前 需要安装ruby,以及redis和ruby连接: yum -y install ruby ruby-de ...