Stable Mex
Chef gives you a sequence $A$ of length $N$. Let $X$ denote the $MEX$ of the sequence $A$. Chef is interested in the count of **positive** values $k$, such that, if every element $A_i$ of $A$ is replaced by $\texttt{max}(A_i-k,0)$, the $MEX$ of the sequence still remains $X$. Find the count of such values. If there are **infinite** such values, print $-1$ instead. As a friendly reminder, the $
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