Блог пользователя amr0

Автор amr0, история, 3 года назад, По-английски

Hello Codeforces! I was trying to solve https://codeforces.com/gym/102920/problem/L using divide and conquer. To get the solution that crosses the midpoint I use the observation that the left endpoint, at index i, will be in a monotonically increasing sequence and the right endpoint, at index j, will be in a monotonically decreasing sequence but I get TLE. This is a code snippet from the code I submitted: https://ideone.com/pRWLDD . Your help is appreciated

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Try the testcase generated by this code:

Generator

Basically, this part of your code can lead N^2 in worst case:

Code

You should understand concept of D&C well to apply it.