spoj tourist: dynamic programming involving going from topleft to bottom rght and then back