Place the tiles - 1D DP

One test case is not passing. Can anybody plz tell me the mistake in my code.
Link - https://ide.codingblocks.com/s/360453