SPOJ FASHION

1025 - Fashion Shows

 * Spoj problem 1025

Summary
Given the "hotness" level of the male/female, print the total hotness of the group.

Explanation
You are given two rows of integers. After sorting, multiply the two numbers in each "column" and add them to a running total for the test case.

Implementations
import java.util.*;

public class Main {

public static void main(String[] args) {

Scanner s =new Scanner(System.in);

int c=0, casos=s.nextInt;

while (c<casos) {

int v1[]=new int[s.nextInt];

for (int i = 0; i < v1.length; i++) {

v1[i]=s.nextInt;

}

int cont=0;int v2[]=new int[v1.length];

for (int i = 0; i < v2.length; i++) {

v2[i]=s.nextInt;

}

Arrays.sort(v1);

Arrays.sort(v2);

for (int i = 0; i < v2.length; i++) {

cont+=v1[i]*v2[i];

}

System.out.println(cont);

c++;

}

}

} by Jack Ibarra

Input
2 2 1 1 3 2 3 2 3 2 1 3 2

Output
5 15