spoj CCOST . Usage of a 2 dimensional fenwick tree.Querying (log(n)^2) a 2 dimensional matrix for sub sum and updating a cell in O(logn)