Make A and B equal
Chef is given two arrays $A$ and $B$ of length $N$ each. In one operation Chef can choose one element of $A$ and one element of $B$ and increase them by $1$. More formally: Chef can pick two integers $i, j$ $(1\le i, j \le N)$ and increment $A_i$ and $B_j$ by $1$. Determine the **minimum** number of operations required to make $A$ and $B$ equal. Output $-1$ if it is not possible to make $A$ an
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start