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

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

This question was asked in hackwithinfy, I could not approach this problem anyhow, can anyone tell me the optimal approach to solve these type of problems and the solution of this specific problem. Here is the question : part1 part2

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

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

Auto comment: topic has been updated by code_tycoon (previous revision, new revision, compare).

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

Seems solvable with a simple segment tree.

Maintain sum of triplets, sum of pairs, and sum of elements in each node of a segment tree. Merging nodes should be pretty straightforward.