Book_allocation

https://ide.codingblocks.com/s/42895
working fine on custom input but on test case it is giving wrong answer

Provide the problem link too.

https://hack.codingblocks.com/contests/c/512/1263

Your have made a min or mistake ,you forgot to add else in “condition” function when curruntpage+a[i]<=ans then only you have to calculate the sum.
corrected your code:
https://ide.codingblocks.com/s/43470

thanks for correction But when my if (condition) gets false it must run that statement without else also

considering it was working well for my custom input and some other input too

Yes,but your computing currentpage always,irrespective of the “if” case.

1 Like