I was recently solving this question using binary search(https://codeforces.net/problemset/problem/1201/C). I came to know about my mistake as my formula for calculating mid was low+(high-low)/2 but instead when I use low+(high-low+1)/2 I get AC.
My questions is when do we use low+(high-low+1)/2. I tried to google it and could not find any link which answers my question.