Not Frequent

Introduction to Greedy Algorithms

Authors: Darren Yao, Melody Yu, Benjamin Qi

Selecting the choice that seems to be the best at the moment at every step of your algorithm.

Greedy Algorithms

Some USACO Bronze problems that appear to be Ad Hoc can actually be solved using greedy algorithms. This idea will be covered in a future module, but we'll introduce the general mindset in this section.

CPHother examples are outside scope of bronze


True "greedy" problems start to show up in silver, though the greedy mindset can be very helpful for bronze problems.

From the above:

A greedy algorithm constructs a solution to the problem by always making a choice that looks the best at the moment. A greedy algorithm never takes back its choices, but directly constructs the final solution. For this reason, greedy algorithms are usually very efficient.

Greedy does not refer to a single algorithm, but rather a way of thinking that is applied to problems; there's no one way to do greedy algorithms. Hence, we use a selection of well-known examples to help you understand the greedy paradigm.

Example: Mad Scientist

Focus Problem – read through this problem before continuing!

Try to come up with a greedy algorithm for problem above.

Correct Greedy Algorithm


Note that not all greedy problems necessarily require mathematical proofs of correctness. It is often sufficent to intuitively convince yourself your algorithm is correct.

Pro Tip

Sometimes, if the algorithm is easy enough to implement, you don't even need to convince yourself it's correct; just code it and see if it passes. Competitive programmers refer to this as "Proof by AC," or "Proof by Accepted."


StatusSourceProblem NameDifficultyTagsSolutionURL
BronzeNormalExternal Sol
Old BronzeNormalExternal Sol
BronzeHardExternal Sol
BronzeHardExternal Sol
SilverHardExternal Sol
BronzeVery HardExternal Sol
SilverVery HardExternal Sol

Module Progress:

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!

Give Us Feedback on Introduction to Greedy Algorithms!

Leave suggestions for us by making a post on the USACO Forum! Ex: Unclear sections, mislabeled problems, etc.