Book allocation problem

sample test case working but test case getting wrng
code:https://ide.codingblocks.com/s/122722

@Faizan-Ali-1395131367301898 I have made some changes, check it.