#include <bits/stdc++.h>
// using namespace std;
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    i64 N;
    std::cin >> N;
    std::vector<i64> a(N);
    rep(i, N) std::cin >> a[i];
    std::sort(begin(a), end(a));
    std::reverse(begin(a), end(a));
    i64 s = a[0];
    std::string ret = std::to_string(a[0]);
    rep(i, N - 1) {
        i64 m = abs(s - a[i + 1] - 100);
        i64 p = abs(s + a[i + 1] - 100);
        if(m < p) {
            ret += "-" + std::to_string(a[i + 1]);
            s -= a[i + 1];
        } else {
            ret += "+" + std::to_string(a[i + 1]);
            s += a[i + 1];
        }
    }
    std::cout << ret << std::endl;
    std::cout << s << std::endl;
}

int main() {
    solve();
    return 0;
}

Battle History

ConfigScoreDate
komachi baby02019/11/22 16:27:33
5 small02019/11/22 16:27:33
5 small02019/11/22 16:27:33
5 small02019/11/22 16:27:33
20 middle02019/11/22 16:27:33
20 middle02019/11/22 16:27:33
20 middle02019/11/22 16:27:33
1000 large9994359543002019/11/22 16:27:33
1000 large02019/11/22 16:27:33
1000 large02019/11/22 16:27:33