#include <bits/stdc++.h>
#include "partition.h"

std::vector<int> solve(std::vector<int> A) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n = A.size();
    std::vector<std::pair<long long, int>> v(n);
    for (int i = 0; i < n; ++i) {
        v[i] = {A[i], i};
    }
    sort(v.begin(), v.end(), std::greater<std::pair<long long, int>>());
    std::vector<std::vector<int>> vec(2);
    for (int i = 0; i < n; ++i) {
        vec[i % 2].push_back(v[i].second);
    }
    std::vector<int> ans;
    for (int i = vec[0].size() - 1; i >= 0; --i) {
        ans.push_back(vec[0][i]);
    }
    for (int i = 0; i < vec[1].size(); ++i) {
        ans.push_back(vec[1][i]);
    }
    return ans;
}