There might some pattern in this sequence but just because n<99999 then I suggest building the sequence and then calculate the maximums. I suggest precalculating all the answers before processing the input. You can keep an additional array of answer ANS[100000] where ANS[i] shows max (A[1],A[2],....A[i]).
No comments:
Post a Comment