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

Want help in solving problem “Spiderman’s workout” using recursion with memoization.
Problem link: Spiderman's Workout – Kattis, Kattis

Please suggest how to approach this kind of problem.