Web Images Video News Maps Gmail more Blog Search Blogger Books Calendar Documents Finance Groups Labs Orkut Patents Photos Products Reader Scholar
Send feedback | Sign out

« Back to front page
A. Minimum Scalar Product
B. Milkshakes
C. Numbers
Ask a question
View my submissions
  Submissions
Minimum Scalar Product
5pt
Correct
2352/2567 users correct (92%)
10pt
Correct
1048/2336 users correct (45%)
Milkshakes
10pt
No submissions
655/1042 users correct (63%)
25pt
No submissions
312/432 users correct (72%)
Numbers
15pt
4 incorrect attempts
577/1925 users correct (30%)
35pt
No submissions
96/364 users correct (26%)
  Top Scores
Bohua100
yuhch123100
neal.wu100
newman100
Plagapong100
Ahyangyi100
Reid100
Qingchun100
ploh100
kubus100
View it.
Round 1A
Rank: 1066
Score: 15
Practice Mode
Minimum Scalar Product
In the practice contest, you may try as many times as you want.
Small input
5 points
Download A-small.inMore options  
Submit
Large input
10 points
Download A-large.inMore options  
Submit

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: Y
where 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
3
1 3 -5
-2 4 1
5
1 2 3 4 5
1 0 1 0 1

Case #1: -25
Case #2: 6

Category  Asked  Question  Answered  Answer
Milkshakes
Announcement
41:39Is it possible that a customer likes both the malted and unmalted type of the same flavor ?43:26Yes.
Milkshakes
Announcement
32:17If two customers want the same type of milkshake, can we satisfy both with one batch?35:29A batch will satisfy all users who want that type (flavor and maltedness) of milkshake.
Minimum Scalar Product
Announcement
6:20What 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
6NumbersEasyIncorrect1h 58m 33s
5NumbersEasyIncorrect1h 28m 59s
4NumbersEasyIncorrect1h 28m 08s
3NumbersEasyIncorrect50m 20s
2Minimum Scalar ProductHardCorrect28m 11s
1Minimum Scalar ProductEasyCorrect25m 53s
DownloadA-small.in.zip
DownloadA-large.in.zipA-large.in.keyPredownload encrypted inputA-large.in.enc
DownloadB-small.in.zip
DownloadB-large.in.zipB-large.in.keyPredownload encrypted inputB-large.in.enc
DownloadC-small.in.zip
DownloadC-large.in.zipC-large.in.keyPredownload encrypted inputC-large.in.enc