← All problemsSign in

Asymmetric Swaps

CodeChefRating 1230Open on judge ↗

Chef has two arrays $A$ and $B$ of the same size $N$. In one operation, Chef can: - Choose two integers $i$ and $j$ $(1 \leq i, j \leq N)$ and swap the elements $A_i$ and $B_j$. Chef came up with a task to find the **minimum** possible value of **($A_{max} - A_{min}$)** after performing the swap operation any (possibly zero) number of times. Since Chef is busy, can you help him solve this task

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start