Cses problemset DP counting towers

hi, I am actually completely clueless abt this ques of Counting towers: plz help me with it:
DP Counting towers