problem 82 solution (Dijkstra slow)