sir,,,i have just learnt how BIT works.....
i was trying to impliment the same for this problem :http://www.spoj.com/problems/HAYBALE/
but,i couldnt get idea how to do it,,,,,could anyone pls help me how to approach this problem using BIT..
thanks in advance.
You could solve it without BIT. Having an array of size N, and operation like add 1 to A..B, you can add 1 to A, and add -1 to B+1. After all operation, travel from 0 to N, doing something like RSQ (Range Sum Query), and you have the heights. Then I think you can handle it. Regards!
Please have a look at this blog. It has everything you need to solve the above question . Its not Binary Indexed Tree though (its about Segment Tree)
As facug91 pointed out, you can solve this problem without using a BIT or ST. For more information on the approach he pointed out, take a look at this editorial http://codeforces.me/blog/entry/6779 problem: Little Girl and Maximum Sum.
Hope this helps!