Maths WorkshopMaths problems with full solutions
Exercise 1240Combinatorics › Pigeonhole principleOlympiadAdded 4 Nov 2026

Monotone subsequences (Erdős–Szekeres)

#pigeonhole#sequences#Erdős–Szekeres

Statement

Let n≥1n\ge1. Prove that every sequence of n2+1n^2+1 distinct real numbers contains an increasing subsequence of length n+1n+1 or a decreasing subsequence of length n+1n+1.

Hint

To each term aia_i attach the pair (xi,yi)(x_i,y_i), where xix_i is the length of the longest increasing subsequence ending at aia_i and yiy_i the length of the longest decreasing subsequence ending at aia_i. Show that these pairs are pairwise distinct.

Show solutionHide solution

Solution

Idea. Label every term by two numbers, and show that the labels never repeat.

Distinct labels. Let i<ji<j.
- If ai<aja_i<a_j, any increasing subsequence ending at aia_i can be extended by aja_j, so xj≥xi+1x_j\ge x_i+1.
- If ai>aja_i>a_j, any decreasing subsequence ending at aia_i can be extended by aja_j, so yj≥yi+1y_j\ge y_i+1.

In both cases (xi,yi)≠(xj,yj)(x_i,y_i)\ne(x_j,y_j).

Counting. Suppose, for contradiction, that all increasing and decreasing subsequences have length at most nn. Then 1≤xi,yi≤n1\le x_i,y_i\le n for all ii, so there are at most n2n^2 possible pairs. But we have n2+1n^2+1 terms with pairwise distinct pairs: contradiction.

Remark. The bound n2+1n^2+1 is sharp.

Lesson. When pigeonhole directly fails, build a cleverly chosen label for each object so that distinct objects get distinct labels.