SPOJ FASHION challenge
you can abuse the fact that 


  All hotness ratings are (integers) on a scale of 0 to 10


Just keep track of how many men/women there are of each score. This looks something like this:

int[] men = new int[11];
for (i = 0; i &lt; modelsWithMe; i++) {
    men[sc.nextInt()]++;
}


Then for the score you need to figure out how to combine the pairs given those frequency arrays.

int m = 10;
int w = 10;
while(m &gt;= 0){
    while(men[m] == 0) {
        m--;
    }
    while(women[w] == 0){
        w--;
    }
    hotnessSum += m*w;
    men[m]--;
    women[w]--;
}


This calculation can still be optimised greatly. If you have 21 man score 10 and 30 women score 10 for example, you could add 21*10*10 to the total and reduce the frequencies of both by 21 instead of looping 21 times to achieve the same total. I'll leave turning this into code to you.