A sub-sequence of a sequence is a sequence which is obtained by deleting zero or more elements from the sequence. You are given a sequence A in which every element is a pair of integers i.e A = [ (a 1 , w 1 ) , (a 2 , w 2 ) ,...,(a N , w N )]. For a sub-sequence B = [ (b 1 , v 1 ) , (b 2 , v 2 ) , .... ,(b M , v M ) ] of the given sequence : We call it increasing if for every i ( 1 <= i < M ) , b i < b i+1 . Weight(B) = v1 + v2 + ... + vM . In short : Given a sequence, output the maximum weight formed by an increasing sub-sequence. I have figured out how to do it in O(n^2) time. How can we do it in O(nlogn) ?
How do I find the solution of a CodeChef problem if it is not given in its editorial?