Skip to content
Back to libraryPart 3 · Graphs and dynamic programming

3.4Dynamic programming I

Before you start

It helps to have read 2.4 Recursion and backtracking and 3.1 Graph search: BFS and DFS. Overall level: Intermediate.

Practice: Dynamic programming I

0 of 4 solved

About these problems

Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.

  1. 1Step sequencesCount the ordered sequences of moves, each of length 1 or 2, whose lengths add up to exactly n, and print the count modulo 1000000007. When n = 0, the empty sequence counts once.ApplyNot started
  2. 2Fewest coinsYou have unlimited copies of n distinct positive coin denominations c1, c2, ..., cn. Find the minimum number of coins needed to make exactly x, or -1 if it is impossible. Making x = 0 needs no coins.ConnectNot started
  3. 3Grid route countA grid has n rows and m columns, and each cell is free or blocked. Count the routes from the top-left cell to the bottom-right cell that move one cell right or down at each step. Every cell on a route, including the start and finish, must be free. Print the count modulo 1000000007.ReasonNot started
  4. 4Separated selectionsYou are given a list of n integers a1, a2, ..., an. Choose any set of positions such that no two chosen positions are adjacent. Find the maximum possible sum of the chosen values. Choosing no position is allowed and gives sum 0.StretchNot started

Read the lesson