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

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

could any one explain the logic for his problem.

i couldn't understand the editorial.

thanks in advance.

http://codeforces.me/problemset/problem/466/C

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

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

I haven't read the editorial, my idea was pretty simple. You know before hand the value that each segment should have. Just that sum / 3. And one segment should be a prefix and the other a sufix, now you just notice that if you pick a non overlaping prefix and suffix which sum would be (global_sum / 3) the middle segment also will satisfy this condition. So the problem looks simple now. For every prefix that satisfy the condition count how many suffix starts after the end of this prefix (just preprocess this calculations to do it in O(1)) The sum of this values is the answer to the problem. I hope it will be useful to you. Here is my code: 7952017.