codeforces A. 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 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 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 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.

Sample test(s)

input

5
10 10 10 10 10
5
2 5
3 13
2 12
1 13
4 6

output

0
12
5
0
16

模拟鸟飞的过程, 暴力法了。

#include <vector>
#include <string>
#include <iostream>
using namespace std;
#define FR(i, n) for (i = 0; i < n; i++)

void ShaassandOskols()
{
	int n = 0, ythBird = 0, xthWire = 0;
	cin>>n;
	vector<int> wires(n);
	int i = 0;
	FR (i, n) cin>>wires[i];

	cin>>n;
	FR (i, n)
	{
		cin>>xthWire>>ythBird;
		if (xthWire > 1) wires[xthWire-2] += ythBird-1;
		if (xthWire < (int)wires.size())
			wires[xthWire] += wires[xthWire-1] - ythBird;
		wires[xthWire-1] = 0;
	}
	FR(i, wires.size())
	{
		cout<<wires[i]<<endl;
	}
}

codeforces A. Shaass and Oskols 题解

时间: 2024-10-06 00:45:03

codeforces A. Shaass and Oskols 题解的相关文章

CodeForces - 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 n from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delici

Codeforces A. Valera and X 题解

判断二维字符串是否满足下面条件: on both diagonals of the square paper all letters are the same; all other squares of the paper (they are not on the diagonals) contain the same letter that is different from the letters on the diagonals. Help Valera, write the progra

Codeforces Round #262 (Div. 2) 题解

A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When

Codeforces Round #FF (Div. 2) 题解

比赛链接:http://codeforces.com/contest/447 A. DZY Loves Hash time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a hash table with p buckets, numbered from 0 to p?-?1. He wants to insert n 

Codeforces D. Giving Awards 412 题解

就是按照一定顺序输出排序. 比如a欠b的钱就不能先输出a然后输出b. 本题的技巧就是,要求的是不能先输出a然后输出b,但是可以先输出b然后输出a. 故此可以按照a欠b的钱的关系,建立图,然后DFS深度优先搜索,然后逆向记录点,输出这些逆向点,也就是a欠b的钱,就先输出b然后输出a,那么这个顺序就满足要求了. 很狡猾的题意.要细心.不然就搞半天都白搞了. 题目连接:http://codeforces.com/problemset/problem/412/D #include <stdio.h>

codeforces A. Slightly Decreasing Permutations 题解

Permutation p is an ordered set of integers p1,??p2,??...,??pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation

Codeforces Round #259 (Div. 2) 题解

A. Little Pony and Crystal Mine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n?>?1) is an n?×?n 

codeforces A. Valera and Plates 题解

Valera is a lazy student. He has m clean bowls and k clean plates. Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl.

Codeforces Round #177 (Div. 2) 题解

[前言]咦?现在怎么流行打CF了?于是当一帮大爷在执着的打div 1的时候,我偷偷的在刷div 2.至于怎么决定场次嘛,一般我报一个数字A,随便再拉一个人选一个数字B.然后开始做第A^B场.如果觉得机密性不高,来点取模吧.然后今天做的这场少有的AK了.(其实模拟赛只做完了4题,最后1题来不及打了) 等等,话说前面几题不用写题解了?算了,让我难得风光一下啦. [A] A. Polo the Penguin and Segments time limit per test 2 seconds mem