This problem is bad. It has too weak testcases since my solution should not be passed(O(n^(5/3)logn)). The essence is how to calculate differences smartly.
CodeForces #119 Div.1 C Weak Memory and Aizu Online Judge 1150 Cliff Climbing
Easy. Remember Single-Source Shortest Path problem on unweighted graph can be solved by Breadth First Search. In some cases, it could be faster than dijkstra.