Median Rearrangement
You have an $n \times n$ matrix $a$. You can rearrange the elements of the matrix in any way. Let $m_1, m_2, \dots, m_n$ be the medians of each row in $a$ after the rearrangement. The goodness of the matrix $a$ is defined as the minimum median among the medians of all rows i.e $\min(m_1, m_2, \dots, m_n)$. Naturally, rearranging values also comes with a cost. The cost of rearrangement is defined a
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