← All problemsSign in

C - Deletion Minimization

An array $c$ of length $m$ is said to be $k$-*good* if it can be rearranged to get an array $b$ such that $$ \gcd(|b_1 - b_2|, |b_2 - b_3|, \ldots, |b_{m-1} - b_{m}|) = k $$ That is, the greatest common divisors of all adjacent differences of $b$ must equal $k$. Here, $|x|$ denotes the absolute value of $x$. For example, $|1| = 1, |-2| = 2, |0| = 0$. Further, all arrays of length $1$ are consi

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