Unable to think recursive equation of problem "Spiderman's workout"

Want help in solving problem “Spiderman’s workout” using recursion with memoization.
Problem link: https://open.kattis.com/problems/spiderman

Please suggest how to approach this kind of problem.