First of all, your descriptions of the problems are ambiguous and inaccurate. For example, in the first problem your sequences "a_1, ..., a_x" and "b_1, ..., b_x" falsely imply that both subsequences have to start at the beginning, but your example contradicts that. Your example also indicates that the subsequences have to be nondecreasing, not increasing. I can't even begin to understand what the second problem is. It's much easier to describe the problems accurately than to solve them, so if you want help you should do that first.
Having said that, if I understand the first problem correctly, the solution is pretty simple. For each horizontal position i from 2 to 12, let c(i) = T if either
Code:
((a_{i-1} <= a_i) and (b_{i-1} <= b_i))
or
Code:
((a_{i-1} <= b_i) and (b_{i-1} <= a_i))
, and c(i) = F otherwise. By convention we can just let c(1) = T. Hence the values c(i) for c=1 to 12 are
T F F F T F F T T F F F
and now you just look for the longest subsequence which has all T's except possibly for an F at the beginning. This is the subsequence "F T T" from i=7 to i=9. In general, for sequences with N elements, the running time is O(N). You do one O(N) sweep to compute the c(i)'s and another O(N) sweep to read off the longest subsequence.
I found a link on Google corresponding to this problem. Unfortunately I can't read Romanian, so I don't know what it's about.
http://<ol class="decimal"><li style....htm</li></ol>