五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
个旧市| 铅山县| 佛山市| 广西| 和田市| 佳木斯市| 会泽县| 莲花县| 辽阳县| 长垣县| 绥阳县| 柞水县| 鄢陵县| 郁南县| 晋城| 明星| 沙洋县| 稻城县| 安西县| 东乡县| 呼和浩特市| 沽源县| 大余县| 太和县| 永定县| 汤阴县| 湖北省| 观塘区| 伊春市| 万源市| 介休市| 洪洞县| 永宁县| 拜泉县| 元阳县| 克山县| 达拉特旗| 兴海县| 偏关县| 梓潼县| 于田县|