// brute force
#include "partition.h"
#include<bits/stdc++.h>
using namespace std;

std::vector<int> solve(std::vector<int> a){
    vector<pair<int, int>>v;
    int n = a.size();
    for(int i = 0; i < n; i++){
        v.push_back({a[i], i});
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    vector<int>d, m;
    int sum_d = 0, sum_m = 0;
    for(int i = 0; i < v.size(); i++){
        if(i%2 == 0){
            d.push_back(v[i].second);
            sum_d += v[i].first;
        }
        if(i%2 == 1){
            m.push_back(v[i].second);
            sum_m += v[i].first;
        }
    }
    if(sum_d > sum_m){
        swap(d, m);
    }
    vector<int>ans;
    for(int i = 0; i < m.size(); i++)ans.push_back(m[i]);
    for(int i = 0; i < d.size(); i++)ans.push_back(d[i]);
    return ans;
}

