← All problemsSign in

AB or C

CodeChefRating 1373Open on judge ↗

You are given $3$ arrays of positive integers $A$, $B$ and $C$, all of length $N$. Now, you need to construct another array $D$ of length $N$ such that $D_i$ is either $A_i$, $B_i$ or $C_i$ for each $1 \le i \le N$. You can independently choose which value to take for each index. Find the minimum possible value of $\max(D) - \min(D)$ when we optimally choose the array $D$. Here, $\max(D)$ repr

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