#include "partition.h"
#include <algorithm>
using namespace std;
const int p2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432};

bool cmppiigfgs(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.first != b.first)
        return a.first > b.first;
    return a.second > b.second;
}

vector<int> solve(vector<int> A) {
    vector<pair<int, int>> newa(A.size());
    vector<int> ansm, ansd, ans;
    for (int i = 0; i < A.size(); i++)
        newa[i] = {A[i], i};
    sort(newa.begin(), newa.end(), cmppiigfgs);
    int m = 0, d = 0;
    for (const auto &p : newa)
        if (m < d)
            ansm.push_back(p.second), m += p.first;
        else
            ansd.push_back(p.second), d += p.first;
    if (m > d) {
        for (const auto i : ansm)
            ans.push_back(i);
        for (const auto i : ansd)
            ans.push_back(i);
    } else {
        for (const auto i : ansd)
            ans.push_back(i);
        for (const auto i : ansm)
            ans.push_back(i);
    }
    return ans;
}
