Advertisement
istinishat

Ternary_Search

Oct 2nd, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///http://codeforces.com/blog/entry/43440
  2. /// MAXIMUM
  3.  
  4. int lo = -1, hi = n;
  5.  
  6. while (hi - lo > 1){
  7.     int mid = (hi + lo)>>1;
  8.     if (f(mid) > f(mid + 1))
  9.          hi = mid;
  10.     else
  11.          lo = mid;
  12. }
  13. //lo + 1 is the answer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement