P8301 [CoE R4 A/Stoi2041] Lady

Background

![](bilibili:BV1fx411N7bU?page=4)

Description

Given two $0$-$1$ sequences $a$ and $b$, both of length $n$. **First**, you may choose some $a_i$ to flip, i.e., change $0$ to $1$ and $1$ to $0$. **Then**, you may permute sequence $a$ in any order. After the above process, it is required that $a_i$ **equals** $b_i$. Find the minimum number of flips.

Input Format

The first line contains a positive integer $n$. The second line contains $n$ numbers representing sequence $a$. The third line contains $n$ numbers representing sequence $b$.

Output Format

Output one integer representing the answer.

Explanation/Hint

### Sample Explanation Input #1: Reorder $a = 110$ into $a = 101$ to meet the requirement, so the minimum number of flips is $0$. Input #2: Flip the fourth bit of $a = 10010$ (counting from left to right), obtaining $a = 10000$, then reorder it to get $a = 00100$, which meets the requirement, so the minimum number of flips is $1$. --- ### Constraints - For $10\%$ of the testdata, $n = 1$. - For another $20\%$ of the testdata, $b_i = 0$. - For another $20\%$ of the testdata, $b_i = 1$. - For $100\%$ of the testdata, $1 \le n \le 10^3$, $a_i \in \{0, 1\}$, $b_i \in \{0, 1\}$. Translated by ChatGPT 5