ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
back to board

Discussion of Problem 1017. Staircases

Solving using the height of last step
Posted by Gokul 21 Apr 2018 01:10
Hi All,

Just want to share my experience solving this problem. I did it like this let the i be the number of bricks available and j be the height of the last step.
S[i][j] = sum(S[i-j][:j]) + (1 if (i-j) < j else 0)

So basically all i am doing is the number of stairs with i bricks and height j is also the same number of stairs with i-j bricks and max height of j - 1(hence the array stops at index j) and one more if i - j bricks are less than height j.

There might be more slick solution avaiable, but this worked for me :)

Edited by author 21.04.2018 01:11