#include <bits/stdc++.h>
#include "partition.h"

using namespace std;

#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back


vector<int> solve(vector<int> a) {
    int n = a.size();


    double sum = 0;

    for(int i = 0;i < n;i++){
        sum += a[i];
    }

    sum /= (double)2;

    vector <int> ans(n);
    for(int i = 0;i < n;i++){
        ans[i] = i;
    }
    int dif = 1e9;

    for (int i = 0;i < (1 << n);i++){
        vector <pair<int,int> > b;
        for(int j = 0;j < n;j++){
            if(1 & (i >> j)){
                b.pb({a[j] , j});
            }
        }
        if((int)b.size() == 0) continue;
        sort(all(b));
        double cnt = 0;
        for(int j = 0;j < (int)b.size() - 1;j++){
            cnt += b[j].ff;
        }
        if(cnt < sum && cnt + b[(int)b.size() - 1].ff >= sum){
            if(abs((int)b.size() - (n - (int)b.size())) < dif){
                dif = abs((int)b.size() - (n - (int)b.size()));
                vector <int> c, d(n);
                for(int j = 0;j < (int)b.size();j++){
                    c.pb(b[j].ss);
                    d[b[j].ss] = 1;
                }
                for(int j = 0;j < n;j++){
                    if(!d[j]) c.pb(j);
                }

                swap(c, ans);
            }
        }
    }

    return ans;
}
