SPOJ ORDERSET TLE

Ohh, i missed that. Thank you so much.
Can you explain the segment tree and fenwick tree approach?