Score : $600$ points
You are given multisets with $N$ non-negative integers each: $A=\{ a_1,\ldots,a_N \}$ and $B=\{ b_1,\ldots,b_N \}$.
You can perform the operations below any number of times in any order.
Your objective is to make $A$ and $B$ equal (as multisets).
Determine whether it is achievable, and find the minimum number of operations needed to achieve it if it is achievable.
Input is given from Standard Input in the following format:
$N$ $a_1$ $\ldots$ $a_N$ $b_1$ $\ldots$ $b_N$
If the objective is achievable, print the minimum number of operations needed to achieve it; otherwise, print -1
.
3 3 4 5 2 4 6
2
You can achieve the objective in two operations as follows.
1 0 1
-1
You cannot turn $\{ 0 \}$ into $\{ 1 \} $.