Code showing wrong answer

My code link - https://ide.codingblocks.com/s/207873
My code is showing wrong error for test case 2 and 3. Why?

I have edited your code… Try to submit it now…

What was the error in my code?

I have multiplied with “t” later on … and have taken a mod value … as
(time_req(a,n,k)*t)%10000003

and also have changed all those lines where you have multiplied it with “t” in bool function as well… Rest code was fine…

Why was the code giving wrong answer? We wanted to find minimum time, so shouldn’t binary search be applied on time? Why didn’t we include t to find start and end position?

No… The search space will include the elements of the array… not the time… Thus after optimising the search space … We will multiply it with “t”…
You can refer to the video as ,

Got it! Thanks for your help.