//水题 #include <iostream> #include <algorithm> #include <cstdio> using namespace std; typedef long long ll; const int MAX_N = 1000; int n; int v1[MAX_N], v2[MAX_N]; void solve(); int main() { int k; freopen("E:\A-large-practice.txt", "r", stdin); // 输入重定向,输入将从 A.txt 文件中读入 freopen("E:\A large output.txt", "w", stdout); // 创建文件,输出重定向,输出数据将保存在 A output.txt 文件中 // scanf("%d", &k); cin >> k; for (int kase = 1; kase <= k; kase++) { cin >> n; for (int i = 0; i < n; i++) cin >> v1[i]; //scanf("%d", v1 + i); for (int i = 0; i < n; i++) cin >> v2[i]; //scanf("%d", v2 + i); cout << "Case #" << kase << ": "; solve(); } fclose(stdin); fclose(stdout); return 0; } void solve() { sort(v1, v1 + n); sort(v2, v2 + n); ll ans = 0; for (int i = 0; i < n; i++) ans += (ll)v1[i] * v2[n - 1 - i]; // printf("%ll ", ans); cout << ans << endl; }