#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> solve(std::vector<int> a){
    vector <pair <int,int> > b;
    int n = a.size();
    for(int i = 0;i < n;i++)b.push_back({a[i],i});
    sort(b.begin(),b.end());
    vector <int> p;
    int sum = 0,hlv = (n + 1) / 2;
    for(int i = 0;i < hlv;i++)sum += b[i].first;
    int l = hlv - 1,r = n - 1,S = 0;
    for(int i = 0;i < n;i++)S += a[i];
    while(true)
    {
        if(2 * sum >= S)break;
        sum += b[r].first - b[l].first;
        l--;
        r--;
    }
    vector <int> used(n);
    for(int i = l;i < hlv;i++)
    {
        p.push_back(i);
        used[i] = 1;
    }
    for(int i = 0;i < l;i++)
    {
        p.push_back(n - i - 1);
        used[n - i - 1] = 1;
    }
    for(int i = 0;i < n;i++)
    {
        if(used[i])continue;
        p.push_back(i);
    }
    for(int i = 0;i < n;i++)p[i] = b[p[i]].second;
    return p;
}