Codeforce 294A - Shaass and Oskols (模拟)

时间:2023-03-09 07:34:03
Codeforce  294A - Shaass and Oskols (模拟)

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.

Codeforce  294A - Shaass and Oskols (模拟)

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 ;
}