Minimum Scalar Product
In the practice contest, you may try as many times as you want.
| Small input 5 points | Download A-small.in |
| Large input 10 points | Download A-large.in |
Problem
You are given two vectors v1=(x1,x2,...,xn) and v2=(y1,y2,...,yn). The scalar product of these vectors is a single number, calculated as x1y1+x2y2+...+xnyn.
Suppose you are allowed to permute the coordinates of each vector as you wish. Choose two permutations such that the scalar product of your two new vectors is the smallest possible, and output that minimum scalar product.
Input
The first line of the input file contains integer number T - the number of test cases. For each test case, the first line contains integer number n. The next two lines contain n integers each, giving the coordinates of v1 and v2 respectively.Output
For each test case, output a line
Case #X: Ywhere X is the test case number, starting from 1, and Y is the minimum scalar product of all permutations of the two given vectors.
Limits
Small dataset
T = 1000
1 ≤ n ≤ 8
-1000 ≤ xi, yi ≤ 1000
Large dataset
T = 10
100 ≤ n ≤ 800
-100000 ≤ xi, yi ≤ 100000
Sample
|
Input |
Output |
2
|
Case #1: -25
|
| Category | Asked | Question | Answered | Answer | ||||
|---|---|---|---|---|---|---|---|---|
| Milkshakes Announcement | 41:39 | Is it possible that a customer likes both the malted and unmalted type of the same flavor ? | 43:26 | Yes. | ||||
| Milkshakes Announcement | 32:17 | If two customers want the same type of milkshake, can we satisfy both with one batch? | 35:29 | A batch will satisfy all users who want that type (flavor and maltedness) of milkshake. | ||||
| Minimum Scalar Product Announcement | 6:20 | What does 'smallest' mean? Is -10 smaller than 1? | 7:01 | -10 is smaller than 1. |
You can not ask questions at this time. Please contact us by email.
You have 6 submissions.
| ID | Problem | Difficulty | Input | Output | Solution | Status | Time |
|---|---|---|---|---|---|---|---|
| 6 | Numbers | Easy | ![]() | ![]() | ![]() | Incorrect | 1h 58m 33s |
| 5 | Numbers | Easy | ![]() | ![]() | ![]() | Incorrect | 1h 28m 59s |
| 4 | Numbers | Easy | ![]() | ![]() | ![]() | Incorrect | 1h 28m 08s |
| 3 | Numbers | Easy | ![]() | ![]() | ![]() | Incorrect | 50m 20s |
| 2 | Minimum Scalar Product | Hard | ![]() | ![]() | ![]() | Correct | 28m 11s |
| 1 | Minimum Scalar Product | Easy | ![]() | ![]() | ![]() | Correct | 25m 53s |
Submissions




