#include "partition.h"
#include <algorithm>
using namespace std;
std::vector<int> solve(std::vector<int> A) {
    vector<bool> V(2*10000000, 0);
    int siz=A.size();
    vector<int> R1(siz), R2(siz);
    int s1=0, s2=0;

    int i1=0, j1=siz-1;
    int i2=0, j2=siz-1;

    for (int k=0; k<siz; k++) {
        if (V[A[k]]==0) {
            R1[i1]=k;
            R2[j2]=k;
            i1++;
            j2--;
            s1+=A[k];
            V[A[k]]=1;
        }
        else {
            R1[j1]=k;
            R2[i2]=k;
            s2+=A[k];
            i2++;
            j1--;
            V[A[k]]=0;
        }
    }

    if (s1>s2) {
        return{R1};
    }
    else {
        return{R2};
    }
}
