graph

SPOJ Problem Set (classical) - Fishmonger

dynamic programming graph Floyd Warshall spoj

Problem: Please find the problem here. Solution: I started the problem using the a simple complete search of all path. Of course, we are not going to be able to enumerate through all the paths. But fortunately we don’t have to, once we have tried a path we can memoize the result as follow. If I am at a certain node n1 with certain an initial time constraint T1before, and with time t12 I can get to node n2, recursively we know the best path to get to market from n2 with budget T-t12 take time T2after and has minimal cost C2after, then we have one best path candidate from n1 to n2 within time constraint T1before that actually spend time T2after + t12 with cost C2after + c12.