Ternary Search problem

Problem link: https://codeforces.com/problemset/problem/1244/E
How to solve it with ternary search? :slightly_smiling_face: