Algorithm Training Minimum product (basic type)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.