r/programmingchallenges • • Sep 27 '15

Help me solve this Fenwick tree problem?

http://wcipeg.com/problem/tc
3 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/heapHeapArray Sep 28 '15

Your problem is the 100,000 length on both axis and not the 300,000 points, or am I wrong? Anyway, take a look here: http://codeforces.com/blog/entry/13813?#comment-187779 (see the problem and then this answer).

2

u/bobhob314 Sep 30 '15

Haha, a little complicated for me but there is a 1D solution my teacher told me about where you sort and insert into the tree in sorted order and query each of them like that. Thanks!

2

u/heapHeapArray Sep 30 '15

Now i see it, way simpler!