Algorithm Training Minimum product (basic type) An array is arranged from large to small, an array from small to large, multiplied by the minimum time limit: 1.0s memory limit: 512.0MB The problem is described to two groups of numbers, each n.
Adjust the order of the numbers in each group so that the two sets of data are multiplied by the same subscript elements, and then added and minimized. Requires the program to output this minimum value.
For example, two groups of numbers are: 1 3-5 and-2 4 1
Then the minimum value corresponding to the sum of products should be:
(-5) * 4 + 3 * (-2) + 1 * 1 =-25 input Format the first line one number T represents the number of data groups. After each set of data, first read into an n, the next two rows per row n number, the absolute value of each number is less than or equal to 1000.
n<=8,t<=1000 output Format A number represents the answer. Sample input 231 3-5-2 4 151 2 3 4 51 0 1 0 1 sample output-256
Algorithm Training Minimum product (basic type)