Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Assume the problem is to check whether you can reach the last building or not.
You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps.
Iterate on the buildings, maintaining the largest r jumps and the sum of the remaining ones so far, and stop whenever this sum exceeds b.