无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1631A - Min Max Swap

2023-06-22 12:21 作者:您是打尖兒還是住店呢  | 我要投稿

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.

中文翻譯:

給定兩個(gè)數(shù)組 a 和 b,每個(gè)數(shù)組都有 n 個(gè)正整數(shù)。 您可以對(duì)它們多次應(yīng)用以下操作:


選擇一個(gè)索引 i (1≤i≤n) 并將 ai 與 bi 交換(即 ai 變?yōu)?bi,反之亦然)。

求 ax(a1,a2,…,an)?max(b1,b2,…,bn) 的最小可能值

? 您可以在應(yīng)用此類操作任意次數(shù)(可能為零)后得到。


輸入

輸入由多個(gè)測(cè)試用例組成。 第一行包含一個(gè)整數(shù) t (1≤t≤100) — 測(cè)試用例的數(shù)量。 測(cè)試用例的描述如下。

每個(gè)測(cè)試用例的第一行包含一個(gè)整數(shù) n (1≤n≤100) — 數(shù)組的長(zhǎng)度。

每個(gè)測(cè)試用例的第二行包含n個(gè)整數(shù)a1,a2,…,an

? (1≤ai≤10000) 其中ai是數(shù)組a的第i個(gè)元素。

每個(gè)測(cè)試用例的第三行包含n個(gè)整數(shù)b1,b2,…,bn

? (1≤bi≤10000) 其中bi是數(shù)組b的第i個(gè)元素

.

就是放2個(gè)數(shù)組,一個(gè)數(shù)組存儲(chǔ)a b對(duì)應(yīng)位置較大的值,一個(gè)數(shù)組存儲(chǔ)a b對(duì)應(yīng)位置較小的值。然后依次就去兩個(gè)數(shù)組的最大值,返回他們的乘積即可;

沒什么算法可言,就是純模擬了;


CF 1631A - Min Max Swap的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
泌阳县| 永吉县| 沿河| 搜索| 黄大仙区| 峨山| 湟中县| 石河子市| 获嘉县| 上犹县| 东乡| 甘谷县| 云南省| 松滋市| 新昌县| 克什克腾旗| 涞源县| 沈丘县| 乌拉特中旗| 三河市| 巴青县| 淮阳县| 容城县| 大丰市| 米泉市| 兴宁市| 沁源县| 丰顺县| 武威市| 崇仁县| 马边| 临西县| 吴川市| 延庆县| 运城市| 忻城县| 西昌市| 连南| 咸宁市| 桓台县| 天台县|