Different Medians
Chef is given an integer $N$. Chef wants to construct a [permutation](https://en.wikipedia.org/wiki/Permutation) $A = [A_1, A_2, \ldots, A_N]$ of $\{1, 2, 3, \ldots, N \}$ that satisfies the following condition: - Let $P_i$ denote the prefix of $A$ of length $i$, i.e, $P_i = [A_1, A_2, \ldots, A_i]$. Then, for every $1 \leq i \lt N$, it must hold that $\text{median}(P_i) \neq \text{median}(P_{i+1
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