OUC_Summer Training_ DIV2_#13 723afternoon
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
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 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.
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 yibirds 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 Input
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<stdio.h>
int main()
{
int a[];
int n,i,j,x,y;
scanf("%d",&n);
for(i = ;i < n;i++)
{
scanf("%d",&a[i]);
}
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&x,&y);
x = x - ;
if(x > && x < n-)
{
a[x - ] += y - ;
a[x + ] += a[x] - y;
a[x] = ;
}
else if(x == )
{
a[] += a[] - y;
a[] = ;
}
else if(x == n - )
{
a[n - ] += y - ;
a[n - ] = ;
}
}
for(i = ;i < n;i++)
{
printf("%d\n",a[i]);
}
return ; }
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is ti and its pages' width is equal to wi. The thickness of each book is either 1 or 2. All books have the same page heights.
Shaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure.
Help Shaass to find the minimum total thickness of the vertical books that we can achieve.
Input
The first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers ti and wi denoting the thickness and width of the i-th book correspondingly, (1 ≤ ti ≤ 2, 1 ≤ wi ≤ 100).
Output
On the only line of the output print the minimum total thickness of the vertical books that we can achieve.
Sample Input
5
1 12
1 3
2 15
2 5
2 1
5
3
1 10
2 1
2 4
3
这个题是用背包,但是我看不懂也不能完全理解。囧~
#include<stdio.h>
int main()
{
int a[];
int n,i,j,x,y;
scanf("%d",&n);
for(i = ;i < n;i++)
{
scanf("%d",&a[i]);
}
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&x,&y);
x = x - ;
if(x > && x < n-)
{
a[x - ] += y - ;
a[x + ] += a[x] - y;
a[x] = ;
}
else if(x == )
{
a[] += a[] - y;
a[] = ;
}
else if(x == n - )
{
a[n - ] += y - ;
a[n - ] = ;
}
}
for(i = ;i < n;i++)
{
printf("%d\n",a[i]);
}
return ; }
OUC_Summer Training_ DIV2_#13 723afternoon的更多相关文章
- OUC_Summer Training_ DIV2_#9 719
其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
- OUC_Summer Training_ DIV2_#16 725
今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...
- OUC_Summer Training_ DIV2_#12(DP1) 723
这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS Memory Limit:32768KB ...
- OUC_Summer Training_ DIV2_#14 724
又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS Memory Limit:262144KB 64bit IO F ...
- OUC_Summer Training_ DIV2_#2之解题策略 715
这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...
- OUC_Summer Training_ DIV2_#7 718
是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS Memory ...
- OUC_Summer Training_ DIV2_#11 722
企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- OUC_Summer Training_ DIV2_#4之数据结构
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS Me ...
随机推荐
- 网络编程之NIO
传统的BIO(Blocking IO)的缺点: 1.基于阻塞式IO建立起来的,导致服务端一直阻塞等待着客户端发起请求,如果客户端不发起,服务端的的业务线程会一直存. 2.弹性伸缩能力差,线程数和客户端 ...
- 微信Emoji表情代码大全
参考网址 因PC端微信表情包不全,部分表情在PC中有显示问题,手机端微信不存在此问题,或者可以使用文字[微笑]这种方式添加微信表情 含义 标准 DoCoMo KDDI 软银 谷歌 微信 ✂复制这列
- html5中本地存储概念是什么?
html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage.sessionStorage用于本地存储一个会话中的数据,这些数据只有在同一个会话中的页 ...
- libusb移植
下载 https://sourceforge.net/projects/libusb/ 编译 # ./configure --build=i686-linux --host=arm-linux --p ...
- vs code 开发小程序会用到的插件
主要介绍一下几个vscode插件,在vscode中搜索插件关键字点击安装即可. 1) vscode weapp api, 语法结构api; 2) minapp-vscode 3) vscode wx ...
- ppp协议解析二
转:http://blog.csdn.net/yangzheng_yz/article/details/11526747 PPP(Point to Point Protocol,点对点协议)协议是为在 ...
- Linux基础篇之FTP服务器搭建(一)
一.配置网络可以访问互联网(没有条件的可以提前下载相关版本的依赖包(也叫安装包,以下统称依赖包)上传到系统中也可以). 二.检查系统中是否存在相关的依赖包. 没有返回信息,说明系统中不存在相关的依赖包 ...
- EasyUI中取的DataGrid中选中行数据
dataGrid中显示列:ItemID,ItemCode,ItemName,Note 一.选中一行 var selRow = $('#dataGrid').datagrid('getSelected' ...
- LoadRunner(6)
一.脚本录制技术细节 1.选择合适的协议: 1)B/S架构:常用Web[HTTP/HTML]协议,如果项目中使用了其它技术,比如Ajax.JDBC.FTP等,就需要选择多协议: 2)C/S架构:常用W ...
- 遍历二叉树 - 基于递归的DFS(前序,中序,后序)
上节中已经学会了如何构建一个二叉搜索数,这次来学习下树的打印-基于递归的DFS,那什么是DFS呢? 有个概念就行,而它又分为前序.中序.后序三种遍历方式,这个也是在面试中经常会被问到的,下面来具体学习 ...