#include using namespace std; // not... long long solveMax(const vector& v, int add, int sub) { int n = v.size(); long long x = 0; for(int i=0; i& v, int add, int sub) { if(sub > 0) return - solveMax(v, sub - 1, add + 1); int n = v.size(); long long x = 0; long long a = 1; for(int i=0; i> n; int add = 0; int sub = 0; vector v; for(int i=0; i> c; if(c == '+') ++ add; else if(c == '-') ++ sub; else v.push_back(c - '0'); } sort(v.begin(), v.end()); cout << solveMax(v, add, sub) << ' ' << solveMin(v, add, sub) << endl; return 0; }