#include <bits/stdc++.h>
#include "partition.h"
using namespace std;
vector<int> solve(vector<int> a) {
    int n = a.size();
    long long difMi = LLONG_MAX;
    int rasp;

    long long tot = accumulate(a.begin(), a.end(), 0LL);
    for(int msc = (1 << n) - 1; msc >= 0; msc--) {
        long long sum = 0;
        for(int j = 0; j < n; j++) {
            if(msc >> j & 1) sum += a[j];
        }

        if(sum * 2 >= tot) {
            long long dif = sum - (tot - sum);
            if(difMi > dif) {
                difMi = dif;
                rasp = msc;
            }
        }
    }

    vector<int> perm;
    for(int i = 0; i < n; i++) {
        if(rasp >> i & 1) perm.push_back(i);
    }

    for(int i = 0; i < n; i++) {
        if(!(rasp >> i & 1)) perm.push_back(i);
    }

    return perm;
}
