My first problem on top coder, GCJ-r1, segment tree problem