#include "partition.h"
#include "iostream"
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;


vector<int> solve(vector<int> A) {

 //   unordered_map <int, bool> meme;
    vector <pair <int, int>> AA(A.size());
    for (size_t io = 0; io < A.size(); io++)
    {
        AA[io] = { A[io],io };
    }

    sort(AA.begin(), AA.end(), [](const pair <int, int>& a, const pair <int, int>& b) { return a.first > b.first; });

    vector <int> aa, bb;
    aa.reserve(A.size());
    bb.reserve(A.size() / 2);
    int64_t BalanseOfTheWorld = 0;
    for (size_t io = 0; io < A.size(); io++)   
    {
        auto i = AA[io].first;
    //    meme[i] = !meme[i];
        if (BalanseOfTheWorld > 0)
        {
            aa.push_back(AA[io].second);
            BalanseOfTheWorld -= i;
        }
        else
        {
            bb.push_back(AA[io].second);
            BalanseOfTheWorld += i;
        }

    }
    for (auto i : bb) aa.push_back(i);
    
    

    return aa;
}
