Book allocation problem

https://ide.codingblocks.com/s/204912 getting correct ouput in vs code but not able to pass a single test case

Hello @chiragbaid7,

Your code is failing for test cases like:
1
4 2
10 20 30 70

Please, correct your logic.

Let me know if you face any difficulty.
Hope, this would help.
Give a like if you are satisfied.