Book Allocation Problem

Link to my code : https://ide.codingblocks.com/s/210147

I am getting AC for sample case and for cases like

1      
5 5     
10 10 10 10 10

resolved

missed an else condition