美文网首页
CodeFoeces-294A

CodeFoeces-294A

作者: ss5smi | 来源:发表于2018-02-28 16:32 被阅读0次

    题目

    原题链接:A. Shaass and Oskols

    题意

    给出n根电线上鸟的情况,再打m次鸟,每次打x线上第y只鸟。被打死的鸟的左边鸟会飞到x-1上,右边的会飞到x+1上。

    代码

    #include<bits/stdc++.h>
    using namespace std;
    int main() {
        int n,s[110],m,x,y;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>s[i];
        }
        cin>>m;
        while(m--){
            cin>>x>>y;
            s[x-1]+=y-1;
            s[x+1]+=s[x]-y;
            s[x]=0;
        }
        for(int i=1;i<=n;i++){
            printf("%d\n",s[i]);
        }
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:CodeFoeces-294A

          本文链接:https://www.haomeiwen.com/subject/fydmxftx.html