Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Regarding SPOJ-KGSS

$
0
0

Problem :SPOJ-KGSS

My approach: I have implemented a segment tree for finding max in [l,r]. Whenever any query is asked I find out the maximum element in [l,r] and then update the segment tree by replacing the maximum element found by -INF.Now, I find out the maximum element which gives me the second largest element in [l,r].At last, I update the first largest back to its initial value. My code:

I am getting TLE. How can I optimize the updation part?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>