• CodeForces


    /////////////////////////////////////////////////////////////////////////////////////////////////////// 
    作者:stxy-ferryman
    声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 
    查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/
    链接被删请百度:stxy-ferryman
    ///////////////////////////////////////////////////////////////////////////////////////////////////////

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

     题意:有个人闲着无聊去打电线上的绿鸭子,而他在打死一只蠢鸭子后,那只鸭子前面的鸭子向左的电线杆上飞,后面的向右飞,如果没了电线杆,它们就飞走了。最后问你每根电线杆上有几只鸭子。

    题解:不必多说,模拟即可

    代码:

    var
      a:array[1..200] of longint;
      n,m,x,y,i,j,k:longint;
    begin
      readln(n);
      for i:=1 to n do
      read(a[i]);
      readln(m);
      for i:=1 to m do
      begin
        readln(x,y);
        if x>1 then a[x-1]:=a[x-1]+y-1;
        if x<n then a[x+1]:=a[x+1]+a[x] -y;
        a[x]:=0;
      end;
      for i:=1 to n do
      writeln(a[i]);
    end.
  • 相关阅读:
    解决 “invalid resource directory name”, resource “crunch”
    Unable to resolve target 'android-19'
    android SDK安装容易出错的原因
    Eclipse启动认定SDK地址,出现Error executing aapt
    解决Android SDK Manager更新下载速度慢
    Vue框架
    JSON
    Django之组件--cookie与session
    Django之组件--中间件
    Django之组件--forms
  • 原文地址:https://www.cnblogs.com/stxy-ferryman/p/7073698.html
Copyright © 2020-2023  润新知