fireworkes's blog

By fireworkes, history, 6 years ago, In English

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

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

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!