help needed - ZCO13003 (CHEWING)

question link : https://www.codechef.com/ZCOPRAC/problems/ZCO13003
my code link : https://www.codechef.com/viewsolution/14255384
getting WA…pls help me out !!

we can’t see your solution.Please share ideone link or pastebin link.

UPD:instead of writing your own binary search function you can use upper bound here which is easy to use.

misd to cmnt out debugging statements in dat link…ignore dat statements !

i donno about upperbound nd lower bounds…!!
if u dnt mind…pls explain it !!

I first learnt about upper bound and lower bound while solving this question.

this may help you

http://www.cplusplus.com/reference/algorithm/upper_bound/

http://www.cplusplus.com/reference/algorithm/lower_bound/

If you don’t understand look at sample codes and output then you will understand .

can u pls explain wts wrong wid my code ???

i think your code fails when the array contains duplicates

Here is my accepted solution
https://pastebin.com/sKgQR21p

1 Like

can u pls debug my code and tell me d exact reason behind its fail…dat would become a great help bro !!

ok i will try

//