plzzz help for ZCO 16001 BookShelves

Plzz let me know what is wrong in this code for ZCO 16001 BookShelves

https://www.codechef.com/viewsolution/21715714

Many testcases are passing however not a single subtasks is passing

Thanks in advance