Master_coder's blog

By Master_coder, history, 7 years ago, In English

how to do this problem with segment tree data structure. https://www.codechef.com/SEPT17/problems/SEACO

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
Rev. 5   Vote: I like it 0 Vote: I do not like it

First of all, you need to count how many times a command will be executed. It can done by starting with higher index and work only for type 2.

Secondly, for each command of type 1 perform this command previously calculated times.

Sorry for my bad English.

»
7 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Almost Same Problem: 295A - Greg and Array

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I think it could be solved using prefix sums :D