First and final try

Using the look "up": that store the current path, and at each step,
check the sum "up", at level r, take r*log(r) time complexity.
Space CP is also r*log(r), as at each step, we need a array which size
is r, to store the path.