For problem 439D there is a ternary search solution that works very well but this is a ternary search on integers and it can go into an endless loop but the author of questions says it works correct.Why does this solution work?if hi = 3 , lo = 1 when answer is 2 ?The ternary search in this state can not reach 2. here is the code http://mirror.codeforces.com/contest/439/submission/6814294
for (int it = 0; it < 100; it++)
there are no endless loop, cause only of 100 iterations.
You are right but look if hi = 3 and lo = 1 and answer is 2 then it can not reach 2 and will print 3;