MKTHNUM from SPOJ--help required

question link : SPOJ.com - Problem MKTHNUM
my code link : JLNF6b - Online C++0x Compiler & Debugging Tool - Ideone.com
im getting TLE…donno whether my logic is correct or not…!!
if wrong pls correct …if correct help me in getting a decent approach !!
thanks in advance : )

I suspect that its the merging of vectors thats giving you TLE. It depends on linearly on size of vector (afaik) and can cause a TLE if limit is strict. I am looking at possible approaches.

Is my logic correct bro @vijju123 ??

The logic seems correct bro. Just try to get around without using vectors. Also, I think concept of persistence is required.

how can we solve it using persistant segment tree ??