• Codeforce 294A


    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.

    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

     题解:莫得撒子好说的读懂题意直接模拟

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <cstdlib>
     7 #include <iomanip>
     8 #include <cmath>
     9 #include <ctime>
    10 #include <map>
    11 #include <set>
    12 using namespace std;
    13 #define lowbit(x) (x&(-x))
    14 #define max(x,y) (x>y?x:y)
    15 #define min(x,y) (x<y?x:y)
    16 #define MAX 100000000000000000
    17 #define MOD 1000000007
    18 #define pi acos(-1.0)
    19 #define ei exp(1)
    20 #define PI 3.141592653589793238462
    21 #define INF 0x3f3f3f3f3f
    22 #define mem(a) (memset(a,0,sizeof(a)))
    23 typedef long long ll;
    24 ll gcd(ll a,ll b){
    25     return b?gcd(b,a%b):a;
    26 }
    27 const int N=105;
    28 const int mod=1e9+7;
    29 bool flag=0;
    30 int a[N]={0};
    31 int main()
    32 {
    33     std::ios::sync_with_stdio(false);
    34     int n,m,x,y;
    35     cin>>n;
    36     for(int i=1;i<=n;i++){
    37         cin>>a[i];
    38     }
    39     if(n==1) {
    40         cin>>m;
    41         if(m==0){//这种情况要考虑一下
    42             cout<<a[1]<<endl;
    43             return 0;
    44         }
    45         cin>>x>>y;
    46         cout<<0<<endl;
    47         return 0;
    48     }
    49     cin>>m;
    50     for(int i=1;i<=m;i++){
    51         cin>>x>>y;
    52         if(x==1){
    53             a[x+1]+=a[x]-y;
    54             a[x]=0;
    55         }
    56         else if(x==n){
    57             a[x-1]+=y-1;
    58             a[x]=0;
    59         }
    60         else {
    61             a[x+1]+=a[x]-y;
    62             a[x-1]+=y-1;
    63             a[x]=0;
    64         }
    65     }
    66     for(int i=1;i<=n;i++)
    67         cout<<a[i]<<endl;
    68     return 0;
    69 }
  • 相关阅读:
    百度正确的打开姿势
    无法安装或运行此应用程序。该应用程序要求首先在"全局程序集缓存(GAC)"中安装程序集 收藏
    ASP.NET智能提示(一)
    全屏窗体的完整方法(转)
    AutoCompleteExtender轻易实现搜索智能提示 附带一点小讨论
    Winform实现百度搜索框智能提示功能( C# )
    C#(asp.net)仿baidu或google智能匹配搜索下拉框
    vs2008 asp.net ajax控件实现百度,谷歌智能搜索
    js实现搜索框智能提示上下移动效果
    sql server 去重复 转帖的
  • 原文地址:https://www.cnblogs.com/wydxry/p/7264072.html
Copyright © 2020-2023  润新知