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
上一篇http://codeforces.com/problemset/problem/545/B Equidistant String
下一篇http://codeforces.com/problemset/problem/743/A Vladik and flights
想对作者说点什么? 我来说一句

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

关闭
关闭
关闭