Here is the link to the problem:
Prob C Div 1
Here are the links to my 2 submissions:
So, I tried solving this question using ternary search as explained in the editorial to this problem.
Here is the link to the editorial of this problem:
EDITORIAL
I have implemented a very simple ternary search in my code. I made the difference between the left limit and the right limit as small as 10^(-9). However, I was still getting the wrong answer on Test Case 26. My answer was only correct up to 5 decimal places of the actual answer but the requirement was that the answer should be correct up to 6 decimal places. I tried to increase the search space by reducing the difference between the left limit and right limit even more. But then my code started giving TLE on test case 4.
I just want to know how do we fix precision issues like these in ternary search or in competitive programming in general.
A little help or some suggested resource that I could look at would really help me. I have never faced precision issues like these before and therefore I am really inexperienced in this.
If you could also have a look at my code to understand what I am trying to do would make things clearer.
THANKS IN ADVANCE.