美文网首页
CodeFoeces-946A

CodeFoeces-946A

作者: ss5smi | 来源:发表于2018-03-10 16:10 被阅读0次

    题目

    原题链接:A. Partition

    题意

    给出序列a,分成b和c序列,求b的和减去c的和的最大值。

    代码

    #include<bits/stdc++.h>
    using namespace std;
    int main() {
        int n,a,B=0,C=0;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a;
            if(a>=0) B+=a;
            else C+=a;
        }
        printf("%d\n",B-C);
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:CodeFoeces-946A

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