CodeFoeces-294A

2018-02-28  本文已影响0人  ss5smi

题目

原题链接: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;
}
上一篇 下一篇

猜你喜欢

热点阅读