DP Guide 1 v2.0
DP Guide 1 v2.0
DP Guide 1 v2.0
Dynamic Programming
Max 1D Range Sum
1. UVA 10684 - The Jackpot (standard; Kadane’s algorithm)
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
1625
2. UVA 00787 - Maximum Sub ... (max 1D range product; be careful with 0; use Java BigInteger)
https://onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=728
3. Kattis - commercials (transform each input by -P; Kadane’s algorithm)
https://open.kattis.com/problems/commercials
4. Kattis - sellingspatulas (-8 per time slot initially; read sale data; 1D range sum; complete search)
https://open.kattis.com/problems/sellingspatulas
5. Kattis - alicedigital
https://open.kattis.com/problems/alicedigital
6. Kattis - purplerain
https://open.kattis.com/problems/purplerain
7. Kattis - shortsell
https://open.kattis.com/problems/shortsell
8. UVA 00507
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
448
9. UVA 12640
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_
problem&problem=4388
0/1 Knapsack
1. UVA 10130 - SuperSale (very basic 0-1 Knapsack problem)
https://onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1071
2. Kattis - knapsack (basic DP Knapsack; print the solution)
https://open.kattis.com/problems/knapsack
5. Kattis - muzicari
https://open.kattis.com/problems/muzicari
6. Kattis - ninepacks
https://open.kattis.com/problems/ninepacks
7. UVA 01213 - Sum of Different Primes (LA 3619 - Yokohama06; extension of 0-1 Knapsack; s: (id,
remN, remK) instead of s: (id, remN))
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
3654
8. UVA 11566 - Let’s Yum Cha (Knapsack variant: double each dim sum; add one parameter to see if
we have bought too many dishes)
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
2613
1
9. UVA 11832 - Account Book (interesting DP; s: (id, val); use offset to handle negative numbers; t:
plus or minus; print solution)
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_
problem&problem=2932
10. UVA 00431
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=
372
11. UVA 00562
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
503
Coin-Change
1. UVA 00674 - Coin Change (basic Coin-Change problem)
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
615
2. Kattis - bagoftiles (count number of ways to do Coin-Change; meet in the middle; DP combinatorics
(n choose k) to find the answer for a+b)
https://open.kattis.com/problems/bagoftiles
3. Kattis - canonical (complete search possible range of counter examples; do both greedy Coin-Change
and DP Coin-Change)
https://open.kattis.com/problems/canonical
4. Kattis - exactchange2 (a variation to the Coin-Change problem; also available at UVa 11517 - Exact
Change)
https://open.kattis.com/problems/exactchange2
5. UVA 00242 - Stamps and ... (LA 5181 - WorldFinals Nashville95; Complete Search + DP Coin-
Change)
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
178
2
6. UVA 10448 - Unique World (after dealing with traversal on tree, you can reduce the original problem
into Coin-Change; not trivial)
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
1389
7. UVA 11259 - Coin Changing Again (part of the problem is DP Coin-Change with restricted number
of coins per type; inclusion-exclusion)
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
2226
8. UVA 00147
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
83
9. UVA 00166
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=
102
10. UVA 00357
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
293
11. UVA 10313
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
1254
12. UVA 11137
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=
2078
3
14. UVA 10131
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
1072
15. UVA 10154
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=
1095