最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

CF 1736A - Make A Equal to B

2023-06-23 13:52 作者:您是打尖兒還是住店呢  | 我要投稿

You are given two arrays a and b of n elements, each element is either 0 or 1.

You can make operations of 2 kinds.

Pick an index i and change ai to 1?ai.

Rearrange the array a however you want.

Find the minimum number of operations required to make a equal to b.

Input

Each test contains multiple test cases. The first line contains a single integer t (1≤t≤400) — the number of test cases. Description of the test cases follows.

The first line of each test case contains a single integer n (1≤n≤100) — the length of the arrays a and b.

The second line of each test case contains n space-separated integers a1,a2,…,an (ai is 0 or 1), representing the array a.

The third line of each test case contains n space-separated integers b1,b2,…,bn (bi is 0 or 1), representing the array b.

Output

For each test case, print the minimum number of operations required to make a equal to b.

Example

------------------------------------------------------

中文:

給定兩個包含 n 個元素的數(shù)組 a 和 b,每個元素不是 0 就是 1。

您可以進行 2 種操作。

選擇一個索引 i 并將 ai 更改為 1?ai。

根據(jù)需要重新排列數(shù)組 a。

求使 a 等于 b 所需的最少運算次數(shù)。

輸入

每個測試包含多個測試用例。 第一行包含一個整數(shù) t (1≤t≤400) — 測試用例的數(shù)量。 測試用例的描述如下。

每個測試用例的第一行包含一個整數(shù) n (1≤n≤100) — 數(shù)組 a 和 b 的長度。

每個測試用例的第二行包含n個空格分隔的整數(shù)a1,a2,…,an(ai為0或1),代表數(shù)組a。

每個測試用例的第三行包含n個空格分隔的整數(shù)b1,b2,…,bn(bi為0或1),代表數(shù)組b。

輸出

對于每個測試用例,打印使 a 等于 b 所需的最少操作數(shù)。

例子

就是先判斷2個數(shù)組之間的差異數(shù)量,然后 將2個數(shù)組排序,看差異的數(shù)量+1,2個取最小值即可;

下面是代碼:


CF 1736A - Make A Equal to B的評論 (共 條)

分享到微博請遵守國家法律
郁南县| 泗洪县| 柘城县| 汤阴县| 彩票| 南靖县| 哈密市| 克东县| 蕲春县| 雅安市| 金川县| 南郑县| 清苑县| 定日县| 灯塔市| 灵台县| 温宿县| 锡林浩特市| 石狮市| 崇阳县| 花垣县| 信宜市| 双峰县| 宁陵县| 原阳县| 桃源县| 平邑县| 成武县| 宝应县| 通辽市| 田林县| 金门县| 婺源县| 铁力市| 清河县| 会昌县| 扎赉特旗| 大悟县| 辽阳市| 通化县| 禹州市|