Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to nfrom 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 thei-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

题解:莫得撒子好说的读懂题意直接模拟

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
const int N=;
const int mod=1e9+;
bool flag=;
int a[N]={};
int main()
{
std::ios::sync_with_stdio(false);
int n,m,x,y;
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
}
if(n==) {
cin>>m;
if(m==){//这种情况要考虑一下
cout<<a[]<<endl;
return ;
}
cin>>x>>y;
cout<<<<endl;
return ;
}
cin>>m;
for(int i=;i<=m;i++){
cin>>x>>y;
if(x==){
a[x+]+=a[x]-y;
a[x]=;
}
else if(x==n){
a[x-]+=y-;
a[x]=;
}
else {
a[x+]+=a[x]-y;
a[x-]+=y-;
a[x]=;
}
}
for(int i=;i<=n;i++)
cout<<a[i]<<endl;
return ;
}

Codeforce 294A - Shaass and Oskols (模拟)的更多相关文章

  1. CodeForces - 294A Shaass and Oskols

    //////////////////////////////////////////////////////////////////////////////////////////////////// ...

  2. Codeforce 287A - IQ Test (模拟)

    In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the ...

  3. Codeforces Round #178 (Div. 2)

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

  4. OUC_Summer Training_ DIV2_#13 723afternoon

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

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

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

  6. Codeforce#354_B_Pyramid of Glasses(模拟)

    题目连接:http://codeforces.com/contest/676/problem/B 题意:给你一个N层的杯子堆成的金字塔,倒k个杯子的酒,问倒完后有多少个杯子的酒是满的 题解:由于数据不 ...

  7. CodeForce 7 B - Memory Manager(模拟)

    题目大意:给你一段内存,要你进行如下的三个操作. 1.分配内存  alloc   X ,分配连续一段长度为X的内存. 如果内存不够应该输出NULL,如果内存够就给这段内存标记一个编号. 2.擦除编号为 ...

  8. CodeForce 439C Devu and Partitioning of the Array(模拟)

     Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...

  9. Kilani and the Game-吉拉尼的游戏 CodeForce#1105d 模拟 搜索

    题目链接:Kilani and the Game 题目原文 Kilani is playing a game with his friends. This game can be represente ...

随机推荐

  1. 容器化 RDS:你须要了解数据是怎样被写&quot;坏&quot;的

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/M2l0ZgSsVc7r69eFdTj/article/details/79877076 容器化 RD ...

  2. RzCheckTree基本使用

    procedure TForm1.Button1Click(Sender: TObject); var i: Integer; begin //循环读取勾选节点代码及内容 //StateIndex 1 ...

  3. update moudle 调用方式

    向数据库中添加数据  ztt_teacher 1:  创建一个 function moudle,设置该moudle类型为  update moudle 2: 向数据库添加数据的代码 FUNCTION ...

  4. emq共享订阅

    emqtt 试用(二)验证 emq 和 mosquito 的共享订阅 1. 多个订阅者都订阅以下主题形式 clientA 订阅  $queue/topic 发布主题名称为 topic1   clien ...

  5. 多级代理 haproxy 传递X-Forwarded-Proto

    有时候后端需要知道客户端是用的http请求还是https请求,所以一般在haproxy加上一个X-Forwarded-Proto头 http-request set-header X-Forwarde ...

  6. [LeetCode] 329. Longest Increasing Path in a Matrix_Hard tag: Dynamic Programming, DFS, Memoization

    Given an integer matrix, find the length of the longest increasing path. From each cell, you can eit ...

  7. [LeetCode] 598. Range Addition II_Easy tag: Math

    做个基本思路可以用 brute force, 但时间复杂度较高. 因为起始值都为0, 所以肯定是左上角的重合的最小的长方形就是结果, 所以我们求x, y 的最小值, 最后返回x*y. Code    ...

  8. phpstorm 用法

    同时打开多个工程,多项目并存 File -> settings -> Directories -> Add Content Root 中添加目录 快速模板 输入fore,按下Tab, ...

  9. python字典对与list对象组合使用小问题

    遇到的低级错误,做个小记录,防止下次在陷进去........ 两行数据,分别每行做为一个字典,存传在list中,但是现在问题来了,第二行的数据会覆盖第一行.结果就是,list存储了的两个元素的数据一样 ...

  10. jquery简介未完成

    jQuery jQuery是一个快速.简洁的javascript框架,是继prototype之后又一个优秀的代码库(或者javascript框架).jQuery设计的宗旨是writeLess,Do M ...