Introduction to DP
Authors: Michael Cao, Benjamin Qi
Speeding up naive recursive solutions with memoization.
Dynamic Programming (DP) is an important algorithmic technique in Competitive Programming from the gold division to competitions like the International Olympiad of Informatics. By breaking down the full task into sub-problems, DP avoids the redundant computations of brute force solutions.
Although it is not too difficult to grasp the general ideas behind DP, the technique can be used in a diverse range of problems and is a must-know idea for competitors in the USACO Gold division.
Great introduction that covers most classical problems. Mentions memoization.
great for all skill levels
examples with nonclassical problems
describes many ways to solve example problem, additional classical examples
also covers many classical problems
starts with DAGs, which are covered in "Topological Sort"
If you prefer watching videos instead, here are some options:
Great Introductory Errichto DP Video
Another Errichto DP video regarding coin change
Another Errichto DP video
more DP videos, but some are more related to interview questions than CP
The next few modules provide examples of some classical problems, or Dynamic Programming problems which are well known. However, classical doesn't necessarily mean common. Since so many competitors know about these problems, problemsetters rarely set direct applications of them.
You should know how to do all of these once you're finished with the DP section. Editorials are available here.
Some tasks are beyond the scope of Gold.
Beginner-friendly classical problems. Some tasks requires input/output files. Here you can check the solutions.
Some of these problems will be mentioned in the next few modules.
Easier USACO problems that don't require many optimizations or complex states.
Note - Ordering of DP Modules
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!