#include "partition.h"
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

std::vector<int> solve(std::vector<int> A)
{
    int n = A.size();
    vector<pair<int,int> >v;
    for(int i = 0; i < n; i++) v.push_back({A[i],i});
    sort(v.begin(),v.end());

    vector<int>v1,v2;
    long long s1 = 0, s2 = 0;

    for(int i = n-1; i >= 0; i--)
    {
        if(s1 <= s2)
        {
            s1 += v[i].first;
            v1.push_back(v[i].second);
        }
        else
        {
            s2 += v[i].first;
            v2.push_back(v[i].second);
        }
    }

    if(s1 < s2)
    {
        swap(s1,s2);
        swap(v1,v2);
    }
    for(int x : v2) v1.push_back(x);
    return v1;
}
