Jack_zhuiyi的博客

do what you want to do.

http://codeforces.com/problemset/problem/946/A Partition

负数则加入C,正数加入B即可

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
#define PI (M_PI)
#define INF (0x3f3f3f3f)
#define MOD (1000000007)
#define EPS (1e-12)
#define MAX (1000000)
#define LEN (MAX+5)
int main()
{
    int n,a,ans = 0;
    cin >> n;
    for(int i = 1;i <= n;++i){
        cin >> a;
        if(a > 0) ans += a;
        else ans -= a;
    }
    cout << ans << endl;
    return 0;
}
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Jack_zhuiyi/article/details/80693383
个人分类: codeforce-greedy
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭