[Solution] Make A Equal to B Codeforces Solution
You are given two arrays and of elements, each element is either or .
You can make operations of kinds.
- Pick an index and change to .
- Rearrange the array however you want.
Find the minimum number of operations required to make equal to .
Each test contains multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The first line of each test case contains a single integer () — the length of the arrays and .
The second line of each test case contains space-separated integers ( is or ), representing the array .
The third line of each test case contains space-separated integers ( is or ), representing the array .
For each test case, print the minimum number of operations required to make equal to .
In the first case, we need only one operation: change to . Now which is equal to .
In the fourth case, the optimal way is to rearrange to get the array .
No comments:
Post a Comment