Last two test case - wrong answer

my solution: https://ide.codingblocks.com/s/417089

question: https://online.codingblocks.com/app/player/178555/content/173713/5385/code-challenge

test case 0,1,2,3: correct answer
test case 4,5: wrong answer

Hello @mohaktrivedi please wait i am checking your code:

@mohaktrivedi i have corrected your code and commented the mistake:


if you have any doubt you can ask here:
Happy Learning!!

@tusharaggarwal272 Yes, I know that we have to apply Binary Search on the range, not on boards[]. I have sorted boards[] in order to initialize the start of Monotonic Search Space in an easier way.
Even in your approach, you have updated s to be the largest element in boards[], so what difference does it make? To find this out I tried to run your code, but it’s not compiling well.

@mohaktrivedi i forgot to change the data type as long long int:


check this:
no if you are sorting the array then you are making the blocks in the dimension in the sorted order but we need to allocate painters in the continuous manner in which it is there in the question.

@tusharaggarwal272 Alright! Got my mistake. Thank you for explaining it. Marked as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.