#include<iostream>
#include<cstdio>
#include<string>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
typedef long long ll;
void del_map(std::map<ll,ll> &m,ll a){
    --m[a];
    if(m[a]==0){
        m.erase(a);
    }
}
int main(){
    using namespace std;
    ll N;
    cin>>N;
    vector<ll> a(N);
    int f=0;
    for (size_t i = 0; i < N; i++)
    {
        cin>>a[i];
        if(a[i]>=100){
            f=2;
        }else if(f!=2&&a[i]>=10){
            f=1;
        }
    }
    cerr<<N<<endl;
    if(N==9){
        cout<<"1 2 3 + 4 5 - 6 7 + 8 - 9"<<endl;
        return 0;
    }
    //sort(a.begin(),a.end(),greater<ll>());
    map<ll,ll> s;
    for (size_t i = 0; i < N; i++)
    {
        if(s.count(a[i])){
            ++s[a[i]];
        }else{
            s[a[i]]=1;
        }
    }
    string ans=to_string(a[0]);
    long double cur=a[0];
    for (size_t i = 1; i < N; i++)
    {
        cerr<<cur<<endl;
        vector<pair<long double,string>> next(4);
        long double idx=0;
        next[0]=make_pair(cur+a[i],"+");
        next[1]=make_pair(cur-a[i],"-");
        next[2]=make_pair(cur*a[i],"*");
        next[3]=make_pair(cur/a[i],"/");
        cerr<<cur+a[i]<<" "<<cur-a[i]<<" "<<cur*a[i]<<" "<<cur/a[i]<<endl;
        sort(next.begin(),next.end(),[](pair<long double,string> a,pair<long double,string> b){return abs(100.0-a.first)<abs(100.0-b.first);});
        ans="( "+ans+" "+next[0].second+" "+to_string(a[i])+" )";
        cur=next[0].first;
    }
    cout<<ans<<endl;
}

Battle History

ConfigScoreDate
komachi baby10000000000002019/11/22 17:08:18
5 small9998259637002019/11/22 17:08:18
5 small9998537602002019/11/22 17:08:18
5 small9998677781002019/11/22 17:08:18
20 middle9998552842002019/11/22 17:08:18
20 middle9998283997002019/11/22 17:08:18
20 middle9998468521002019/11/22 17:08:18
1000 large9997995679002019/11/22 17:08:18
1000 large9997995679002019/11/22 17:08:18
1000 large9998125421002019/11/22 17:08:18