A - Shaass and Oskols

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

Input
  1. 5
    10 10 10 10 10
    5
    2 5
    3 13
    2 12
    1 13
    4 6
Output
  1. 0
    12
    5
    0
    16
Input
  1. 3
    2 4 1
    1
    2 2
Output
  1. 3
    0
    3
    这个题就没有什么好说的啦,从头到尾模拟一下就好了。题意也特别好理解哦。
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a[];
  5. int n,i,j,x,y;
  6. scanf("%d",&n);
  7. for(i = ;i < n;i++)
  8. {
  9. scanf("%d",&a[i]);
  10. }
  11. int t;
  12. scanf("%d",&t);
  13. while(t--)
  14. {
  15. scanf("%d%d",&x,&y);
  16. x = x - ;
  17. if(x > && x < n-)
  18. {
  19. a[x - ] += y - ;
  20. a[x + ] += a[x] - y;
  21. a[x] = ;
  22. }
  23. else if(x == )
  24. {
  25. a[] += a[] - y;
  26. a[] = ;
  27. }
  28. else if(x == n - )
  29. {
  30. a[n - ] += y - ;
  31. a[n - ] = ;
  32. }
  33. }
  34. for(i = ;i < n;i++)
  35. {
  36. printf("%d\n",a[i]);
  37. }
  38. return ;
  39.  
  40. }
  1.  
B - Shaass and Bookshelf

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

Input
  1. 5
    1 12
    1 3
    2 15
    2 5
    2 1
Output
  1. 5
Input
  1. 3
    1 10
    2 1
    2 4
Output
  1. 3
  1. 这个题是用背包,但是我看不懂也不能完全理解。囧~
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a[];
  5. int n,i,j,x,y;
  6. scanf("%d",&n);
  7. for(i = ;i < n;i++)
  8. {
  9. scanf("%d",&a[i]);
  10. }
  11. int t;
  12. scanf("%d",&t);
  13. while(t--)
  14. {
  15. scanf("%d%d",&x,&y);
  16. x = x - ;
  17. if(x > && x < n-)
  18. {
  19. a[x - ] += y - ;
  20. a[x + ] += a[x] - y;
  21. a[x] = ;
  22. }
  23. else if(x == )
  24. {
  25. a[] += a[] - y;
  26. a[] = ;
  27. }
  28. else if(x == n - )
  29. {
  30. a[n - ] += y - ;
  31. a[n - ] = ;
  32. }
  33. }
  34. for(i = ;i < n;i++)
  35. {
  36. printf("%d\n",a[i]);
  37. }
  38. return ;
  39.  
  40. }
  1.  

OUC_Summer Training_ DIV2_#13 723afternoon的更多相关文章

  1. OUC_Summer Training_ DIV2_#9 719

    其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...

  2. OUC_Summer Training_ DIV2_#5

    这是做的最好的一次了一共做了4道题  嘻嘻~ A - Game Outcome Time Limit:2000MS     Memory Limit:262144KB     64bit IO For ...

  3. OUC_Summer Training_ DIV2_#16 725

    今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...

  4. OUC_Summer Training_ DIV2_#12(DP1) 723

    这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS     Memory Limit:32768KB   ...

  5. OUC_Summer Training_ DIV2_#14 724

    又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS     Memory Limit:262144KB     64bit IO F ...

  6. OUC_Summer Training_ DIV2_#2之解题策略 715

    这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...

  7. OUC_Summer Training_ DIV2_#7 718

    是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS     Memory ...

  8. OUC_Summer Training_ DIV2_#11 722

    企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &am ...

  9. OUC_Summer Training_ DIV2_#4之数据结构

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS     Me ...

随机推荐

  1. 查看PHP指定扩展的版本信息

    命令:php --ri 扩展名

  2. liunx pip安装

    方法一 wget https://bootstrap.pypa.io/get-pip.py python get-pip.py 方法二 wget https://pypi.python.org/pac ...

  3. 17.SpringMVC核心技术-拦截器

    SpringMVC 中的 Interceptor 拦截器是非常重要和相当有用的,它的主要作用是拦截指定 的用户请求, 并进行相应的预处理与后处理.其拦截的时间点在“处理器映射器根据用户提 交的请求映射 ...

  4. Linux部署tomcat服务常用命令

    cd / 转到根目录 ps -ef|grep tomcat查看进程 ./bin/shutdown.sh 关闭 rm -r logs/* 清除日志 ps -ef|grep tomcat查看进程 ./bi ...

  5. Maven的下载及安装

    版权申明:本文为博主原创文章,欢迎大家转载.转载请声明转载处为:https://www.cnblogs.com/qxcxy-silence/p/10808321.html 1.下载Maven; 1). ...

  6. 【Day4】3.urllib模块使用案例

    import urllib.request as ur ret = ur.urlopen('https://edu.csdn.net/').read() with open('edu.html','w ...

  7. 手动编译用于i.MX6系列ARM的交叉编译SDK

    前言: 在前一节中,在使用别的机器(系统:UBUNTU14.04)上编译好的交叉编译SDK,配置在我的电脑(系统:UBUNTU16.04)上,用于bazel编译Tensorflow时会报arm-pok ...

  8. c#使用 NServiceKit.Redis 封装 RedisHelper

    在说StackExchange.Redis 的时候说了,因为我们的项目一直.net4.0不升级,没有办法,我说的不算,哈哈,又查了StackExchange.Redis在.net4.0使用麻烦,所以选 ...

  9. 如何实现swipe、tap、longTap等自定义事件

    前言 移动端原生支持touchstart.touchmove.touchend等事件,但是在平常业务中我们经常需要使用swipe.tap.doubleTap.longTap等事件去实现想要的效果,对于 ...

  10. 莫比乌斯函数介绍&&基础

    定义 设正整数$N$按照算术基本定理分解质因数为$N=p_1^{c_1}p_2^{c_2} \cdots P_m^{c_m}$,定义函数: $$\mu(N)= \left\{\begin{matrix ...