TLE on submission of code

The solution is passing few manual testcases but giving TLE on submitting.How can be the time complexity reduced further?

this is the link of code https://ide.codingblocks.com/s/261138

@shubham_garud5 you are already using binary search, so the code should not give TLE. There are two problems with your code.

  1. The input format is not correct. There will only be 1 test case for each test file, so you dont have to take input for t.
  2. Use long long int as the range of xi is quite large.

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.