You are looking for the minimum average.
Combination of A,B is {5,2,2,7,1} - this has average 17/5=3.4
A is {5,2,2} - this has average 9/3 = 3
B is {7,1} - this has average 8/2 = 4
The minimum-average subsequence (here) is A. That has THREE elements.
The best subsequence overall is {2,2} - this has average 4/2 = 2 and starts at index 1.
For a general proof, if A has nA elements and B has nB elements then the combined sequence AB has average
(nA.<A> + nB.<B>) / (nA+nB) |
where <.> denotes an average. Thus the average of the combined sequence is
where r is a number between 0 and 1.
Hence, <A,B> lies between <A> and <B>.
Hence, the minimum of <A>, <B> and <A,B> must be one of <A> or <B> - i.e. the smaller parts. Since you aren't allowed a small part of length 1, continuing downward inductively the smallest average (or the largest average, for that matter) must occur for a subsequence of length 2 or 3.