# help me to solve the problem

how this problem can we solved using LIS dp method www.spoj.com/problems/MSTICK/

@s512
this problem can be solved in many ways but an easy way solve this problem is Segtree :

first of all this problem involves range query (finding maximum and minimium in a range but without updation) one you are gone through the tutorial given on Geeks for Geeks you are comfortable witht this . then you are only need to query ranges for the maximum and minimum element in the range .
for this purpose eith you can maintain two seg tree or you can create two entries in a single seg tree .

refer this solution for further clarification::http://www.codechef.com/viewsolution/3641982

and check the use of double instead of float it cost me many WAs…

feel free to cast votes if you like it.

feel free to ask anything if you are not comfortable with my words…

however same can be done with sqrt decomposition with relatively higher time bound of O(n(sqrt(n))) per query.

hey i dont know why but firstly you acccepted my answer and then again rejected why this so .you were not forced to accept it that’w y i m asking

hey i dont know why but firstly you acccepted my answer and then again rejected why this so .you were not forced to accept it that’w y i m asking

//