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.

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.
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
题解:莫得撒子好说的读懂题意直接模拟
#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 (模拟)的更多相关文章
- CodeForces - 294A Shaass and Oskols
//////////////////////////////////////////////////////////////////////////////////////////////////// ...
- Codeforce 287A - IQ Test (模拟)
In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the ...
- 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 ...
- CodeForces 294B Shaass and Bookshelf 【规律 & 模拟】或【Dp】
这道题目的意思就是排两排书,下面这排只能竖着放,上面这排可以平着放,使得宽度最小 根据题意可以得出一个结论,放上这排书的Width 肯定会遵照从小到大的顺序放上去的 Because the total ...
- Codeforce#354_B_Pyramid of Glasses(模拟)
题目连接:http://codeforces.com/contest/676/problem/B 题意:给你一个N层的杯子堆成的金字塔,倒k个杯子的酒,问倒完后有多少个杯子的酒是满的 题解:由于数据不 ...
- CodeForce 7 B - Memory Manager(模拟)
题目大意:给你一段内存,要你进行如下的三个操作. 1.分配内存 alloc X ,分配连续一段长度为X的内存. 如果内存不够应该输出NULL,如果内存够就给这段内存标记一个编号. 2.擦除编号为 ...
- 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 ...
- Kilani and the Game-吉拉尼的游戏 CodeForce#1105d 模拟 搜索
题目链接:Kilani and the Game 题目原文 Kilani is playing a game with his friends. This game can be represente ...
随机推荐
- python安装提示错误Could not find a version that satisfies the requirement dateutil
今天ytkah在安装python3组件时提示如下错误,这个是缺少依赖的问题,就试着用pip3 install dateutil,但还是提示同样的错误,怎么处理呢? Could not find a v ...
- 20171018 在小程序页面去获取用户的OpenID
1. 在小程序的.js 文件中增加代码 //加载页面时到后台服务去获取openID onLoad: function (options) { //OpenId wx.login({ //获取code ...
- 报错解决——Failed to load resource: the server responded with a status of 404 (Not Found) favicon.ico文件找不到
Django项目开发完成后在本地运行没问题,但在推到服务器上后出现报错Failed to load resource: the server responded with a status of 40 ...
- what's the python之python介绍
其实这一篇文章的大部分都是啰嗦话,大部分在百度百科中都有详尽的叙述.既然决定学python了就要风雨兼程,你不用洞悉python到底是什么,你只要知道这是一门编程语言,跟Java.C++等语言一样都是 ...
- Redis入门到高可用(二)—— Redis启动及使用
1. 三种启动方式 ♦️ 最简启动 ./redis-server 使用Redis默认配置进行启动; ♦️ 动态参数启动 * redis-server --port 6380 更改端口为6380并 ...
- javascript篇-知道value值,返回对象中的key值
前提是,value值是唯一的,业务中有这样一个需求,代码如下:
- 实例:使用puppeteer headless方式抓取JS网页
puppeteer google chrome团队出品的puppeteer 是依赖nodejs和chromium的自动化测试库,它的最大优点就是可以处理网页中的动态内容,如JavaScript,能够更 ...
- 多线程——实现Runnable接口实现一个多线程
实现Runnable接口实现一个多线程 Runnable接口源码: package java.lang; //Runnable接口源码只有一个run方法 public interface Runnab ...
- [django]drf知识点梳理-分页
msyql分页 limit offset https://www.cnblogs.com/iiiiiher/articles/8846194.html django自己实现分页 https://www ...
- heapy() :python自带的堆排序
堆是一个二叉树,其中每个父节点的值都小于或等于其所有子节点的值.整个堆的最小元素总是位于二叉树的根节点.python的heapq模块提供了对堆的支持. 堆数据结构最重要的特征是heap[0]永远是最小 ...