Problem

Source: SMO Junior 2019 Q5

Tags: combinatorics



Let $n$ be a positive integer and consider an arrangement of $2n$ blocks in a straight line, where $n$ of them are red and the rest blue. A swap refers to choosing two consecutive blocks and then swapping their positions. Let $A$ be the minimum number of swaps needed to make the first $n$ blocks all red and $B$ be the minimum number of swaps needed to make the first $n$ blocks all blue. Show that $A+B$ is independent of the starting arrangement and determine its value.