2023-06-22 14:25:14 来源 : 哔哩哔哩
You are given two arrays a and b of n positive integers each. You can apply the following operation to them any number of times:
Select an index i (1≤i≤n) and swap ai with bi (i. e. ai becomes bi and vice versa).
Find the minimum possible value of ax(a1,a2,…,an)⋅max(b1,b2,…,bn)
(资料图片)
you can get after applying such operation any number of times (possibly zero).
Input
The input consists of multiple test cases. The first line contains a single integer t (1≤t≤100) — the number of test cases. Description of the test cases follows.
The first line of each test case contains an integer n (1≤n≤100) — the length of the arrays.
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤10000) where ai is the i-th element of the array a.
The third line of each test case contains n integers b1,b2,…,bn (1≤bi≤10000) where bi is the i-th element of the array b.
中文翻译:
给定两个数组 a 和 b,每个数组都有 n 个正整数。 您可以对它们多次应用以下操作:
选择一个索引 i (1≤i≤n) 并将 ai 与 bi 交换(即 ai 变为 bi,反之亦然)。
求 ax(a1,a2,…,an)⋅max(b1,b2,…,bn) 的最小可能值
您可以在应用此类操作任意次数(可能为零)后得到。
输入
输入由多个测试用例组成。 第一行包含一个整数 t (1≤t≤100) — 测试用例的数量。 测试用例的描述如下。
每个测试用例的第一行包含一个整数 n (1≤n≤100) — 数组的长度。
每个测试用例的第二行包含n个整数a1,a2,…,an
(1≤ai≤10000) 其中ai是数组a的第i个元素。
每个测试用例的第三行包含n个整数b1,b2,…,bn
(1≤bi≤10000) 其中bi是数组b的第i个元素
.
就是放2个数组,一个数组存储a b对应位置较大的值,一个数组存储a b对应位置较小的值。然后依次就去两个数组的最大值,返回他们的乘积即可;
没什么算法可言,就是纯模拟了;