Codeforces Round 825 (Div. 2)
A
Make A Equal to B
Codeforces
800
原题
←B →
翻译中…

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 $a_i$ to $1-a_i$.
  • 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 \leq t \leq 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 \leq n \leq 100$) — the length of the arrays $a$ and $b$.

翻译中…

The second line of each test case contains $n$ space-separated integers $a_1,a_2,\ldots,a_n$ ($a_i$ is $0$ or $1$), representing the array $a$.

翻译中…

The third line of each test case contains $n$ space-separated integers $b_1,b_2,\ldots,b_n$ ($b_i$ 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$.

翻译中…

Note

翻译中…

In the first case, we need only one operation: change $a_1$ to $1-a_i$. Now $a = [0, 0]$ which is equal to $b$.

翻译中…

In the second case, the optimal way is to rearrange $a$ to get the array $[0, 1, 11$. Now $a = [0, 0, 1]$ which is equal to $b$.

翻译中…

In the second case, one of optimal ways would be to first change $a_3$ to $1 - a_3$, then rearrange $a$.

翻译中…

In the third case, no operation is needed.

翻译中…

In the fourth case, the optimal way is to rearrange $a$ to get the array $[0, 1, 1, 0]$.

翻译中…

样例

Input #1
5
3
1 0 1
0 0 1
4
1 1 0 0
0 1 1 1
2
1 1
1 1
4
1 0 0 1
0 1 1 0
1
0
1
Output #1
1
2
0
1
1
InputCopy OutputCopy
题目信息
题号
1736A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。