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

Автор fireworkes, история, 6 лет назад, По-английски

My code for 903D - Almost Difference has got Time limits. My solution is 33798061, but I could not fix the problem. Can anyone help me? This is my code : CODE

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

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

Your solution is O(n2) and 1 ≤ n ≤ 200000. That is not nearly fast enough to run under 2 seconds. If you want, you could try reading the editorial to that problem: http://codeforces.com/blog/entry/56330.

It gives a solution. This is not a simple problem which can be brute forced. If you happen to want to do those sort of problems, look at problems A and B in Div. 2 rounds.

Best of luck!