Distinct Numbers
Given an array $A$ consisting of $N$ **distinct** integers $(1 \le A_i \le 2 \cdot N)$, we have to perform $K$ moves. We perform the following steps in one move: - Select an integer $X$ such that $1 \le X \le 2 \cdot N$ and $X \ne A_i$ for all $i$ $(X$ is not equal to any element of the current array$)$. - Append $X$ to $A$. - The *score* of this move $= (\max_{1 \le i \le |A|} A_i) - X$. Note
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