MrDepomposition's blog

By MrDepomposition, history, 7 years ago, In English

hello i am writing this blog because i asked a question but havent got asnwer for it, please explain me why do we need to use segment tree to calculate sums, why cant we just use c++ operator + (read more about this operator here — https://www.w3schools.com/cpp/cpp_operators.asp)

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

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

I hope you're kidding

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

The + operator in general won't give you the sum of an array over an index range [l...r] in log(N) time. A segment tree will.

»
7 years ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

i am trying to solve this problem — https://codeforces.me/problemset/problem/409/H?locale=ru
but my segment tree solution fails

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

Its big brain time!