y0uKn0wWh0's blog

By y0uKn0wWh0, 20 months ago, In English

i was trying to solve this problem and i got tle on test 12

why ?

https://mirror.codeforces.com/contest/939/submission/277938020

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
20 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

There are two likely cases here:

  1. Your binary search never terminates

  2. You used more than 7 query (I think this is likely since you're doing ternary search wrong)

»
20 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

You have in your code while(l <= r). This loop will never end.