Lemma › Guides › Greedy arguments in olympiad combinatorics: when they work
Guide

Greedy arguments in olympiad combinatorics: when they work

26 September 2026

Greedy is the first idea anyone has on a construction problem: take the best available move, then the next best, and hope. It is also the idea most often written up and marked zero, because the write-up proves nothing. The algorithm was never the hard part. The hard part is knowing whether greedy actually works here, and then saying why in a way a marker can check.

So this is not a description of greedy algorithms. It is a guide to recognising when a greedy argument is available, and to the two sentences every greedy proof owes.

The signals

Greedy is worth trying when the problem has some of these features. None is decisive alone, but two together are a strong hint.

Greedy suggests itself on far more problems than it solves. The signals tell you to try it. They do not tell you it will work, and on a surprising fraction of problems the most obvious greedy rule is simply wrong.

The two obligations

Every algorithmic or greedy argument has two halves, and a write-up that merges them usually proves only one.

  1. The step is always available. At every stage the greedy move exists: the procedure never gets stuck. For an existence problem this is often the entire difficulty.
  2. The result is correct. When the procedure ends, the thing it built has the required property, or for an optimisation problem, nothing does better. The standard tool here is the exchange argument: take any optimal answer and show you can swap its choices for greedy's, one at a time, without making it worse.

If you cannot say which of the two your problem is really about, you are not ready to write.

Watching it work: never getting stuck

Every tournament has a path through all the players, each beating the next. Build it greedily: order the players one at a time, inserting each new player somewhere in the path already built.

Obligation 2 is free. Inserting a player between two neighbours they fit between keeps the path a path. So the whole problem is obligation 1: is there always somewhere to put the new player?

Read along the existing path and write W where the new player beats that person and L where they lose. If the first letter is W, put them at the front. If the last letter is L, put them at the back. Otherwise the string starts with L and ends with W, so somewhere an L is immediately followed by a W, and the new player slots in exactly there: beaten by the person before, beating the person after.

That is a discrete intermediate value argument, and it is the most common way obligation 1 gets discharged. Notice that the greedy step here is "insert anywhere that works", not "insert at the best place". Greedy does not have to mean optimising. It means committing to each piece and never going back.

When greedy is simply wrong

Two standard examples, both worth carrying around as reflexes.

Making change. With coins worth 11, 33 and 44, pay 66. Greedy takes the largest coin that fits, so 4+1+14 + 1 + 1, three coins. But 3+33 + 3 is two. With the coins 11, 55, 1010 and 2525 greedy happens to be optimal for every amount, but that is a fact about those particular coins, and it has to be proved for them. It is not a property of greedy.

Scheduling. You have talks with start and end times and want to attend as many as possible without overlap. There are three natural greedy rules, and only one works.

Before you prove a greedy rule, spend two minutes trying to break it on an example with three or four objects. If it survives, that is weak evidence it works. If it breaks, you have saved the time a proof of something false would have cost.

The shape of the exchange argument is worth memorising, because it transfers: greedy's first choice is at least as good as the optimum's first choice, and choosing it leaves at least as much room for the rest. If you can prove both halves of that sentence for your rule, you have a proof.

Greedy as a proof tool

The most useful greedy arguments in olympiad combinatorics are not algorithms anyone wants to run. They are procedures you describe only so that you can count what they produce.

Take the Erdős–Szekeres theorem: any sequence of mn+1mn + 1 distinct reals has an increasing subsequence of length m+1m + 1 or a decreasing one of length n+1n + 1. Here is a greedy proof. Deal the numbers into piles, left to right in the order they appear: each number goes on top of the leftmost pile whose top is larger than it, or starts a new pile on the right if there is none.

Two facts about this procedure, and they are the two obligations in disguise:

Now finish with pigeonhole. If no increasing subsequence has length m+1m + 1, there are at most mm piles. There are mn+1mn + 1 numbers, so some pile holds at least n+1n + 1 of them, and that pile is a decreasing subsequence.

The bound is exact, which is worth checking rather than assuming: 7,8,9,4,5,6,1,2,37, 8, 9, 4, 5, 6, 1, 2, 3 has mn=9mn = 9 terms for m=n=3m = n = 3, and its longest increasing and decreasing subsequences both have length 33.

The archive's solution to that problem uses a different argument, labelling each term with a pair of numbers. Knowing two proofs of the same statement is not redundancy. It is how you find out which idea the problem was really about.

What to practise

Take ten "show it is always possible" or "find the maximum" combinatorics problems. For each one, write down a greedy rule, try to break it on a tiny example, and if it survives, write one line for each obligation: why the step is always available, and why the result is right. Do not write full solutions. Deciding whether greedy is viable, in two minutes, is the skill a timed paper actually rewards.

Lemma teaches algorithmic and greedy constructions as a named technique, alongside the monovariant arguments that prove a procedure stops. The problem archive has both problems above in full, each with a marking rubric. And the daily problem posts a new one every day at three difficulties, no account needed.

Related guides

Train it on Lemma

Every technique here is taught explicitly, in order. 125 lessons, 1206 curated problems and unlimited generated practice at six difficulties. Free to start, no card, and every paid plan opens with 3 free days.

Find your level