logo AlgoBeat OnlineJudge
登录 注册

#213584. [GCJ 2008 #1A] Minimum Scalar Product

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given two vectors and . The scalar product of these vectors is a single number, calculated as .

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.

输入格式

The first line of the input file contains integer number - the number of test cases. For each test case, the first line contains integer number . The next two lines contain integers each, giving the coordinates of and respectively.

输出格式

For each test case, output a line

Case #:

where is the test case number, starting from 1, and is the minimum scalar product of all permutations of the two given vectors.

样例

样例输入 1

2
3
1 3 -5
-2 4 1
5
1 2 3 4 5
1 0 1 0 1

样例输出 1

Case #1: -25
Case #2: 6

数据范围与提示

Limits

Small dataset (5 Pts, Test set 1 - Visible)

Large dataset (10 Pts, Test set 2 - Hidden)