Data Structure Problem: How do I optimize my solution for SPOJ KQUERY2 — K-query II?

Revision en1, by Tobby_And_Friends, 2016-09-06 20:10:09

I tried to implement the problem using segment tree and multisets. I got a verdict of TLE. How can I optimize my code? Or is there a better solution?

Problem link: http://www.spoj.com/problems/KQUERY2/en/

Solution link: http://ideone.com/gDAmUW

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Tobby_And_Friends 2016-09-06 20:10:09 334 Initial revision (published)