# Difference between revisions of "2020 USOJMO Problems/Problem 1"

## Problem

Let $n \geq 2$ be an integer. Carl has $n$ books arranged on a bookshelf. Each book has a height and a width. No two books have the same height, and no two books have the same width. Initially, the books are arranged in increasing order of height from left to right. In a move, Carl picks any two adjacent books where the left book is wider and shorter than the right book, and swaps their locations. Carl does this repeatedly until no further moves are possible. Prove that regardless of how Carl makes his moves, he must stop after a finite number of moves, and when he does stop, the books are sorted in increasing order of width from left to right.

## Solution

WLOG let the books have widths and heights of 1, 2, 3,..., and n. First we will show that Carl can only make finitely many moves.

Note hat two books can never be swapped more than once with each other. This is because after a first swap, the wider book will be to the left of the other, so they can never be swapped back.

Now note that the book with width 1 can only ever move left, as it is the skinniest book. The book with width 2 can only move right once (at most), when it is swapped with the book of width 1. In general, the book of width k can only move right at most $k-1$ times, so each book can only move finitely many times. Thus, since 2 books must move for each move, Carl can only make finitely many moves.

Now we will show that the books are in increasing order of width when Carl is done making moves. Assume otherwise for the sake of contradiction. Now let $f(k)$ be the width of the book in the kth spot from the left. Since the books are not in increasing order of width, there must be i such that $f(i)>f(i+1)$, for $1\leq i\leq n-1$.

Claim: The ith book must be shorter than the $(i+1)$th book. Proof: Assume otherwise for contradiction. Then the ith book must have started to the right of the $(i+1)$th book, since the ith book is taller. However, the ith book is now to the left of the $(i+1)$th book, so they must have been swapped at some point. But since $f(i)>f(i+1)$, the ith book is also wider. But the ith book started to the right, so since it was wider it cannot have been swapped with the $(i+1)$th book, so we arrive at a contradiction. $\blacksquare$

From the claim, the ith book must be shorter than the $(i+1)$th book. But since the ith book is also wider by definition (as $f(i)>f(i+1)$), Carl can swap those two books, so he still has legal moves and we arrive at a contradiction, so we are done. $\blacksquare$

~MortemEtInteritum