An array of students age is given : $ A = \{ A_1,A_2, ..., A_n \} $. Form maximum number of teams such that the sum of age for each team is more than 18. Note that each team consists of only 2 people.
I came across this question in an algorithm book without any answer.
My attempt :
Sort A in ascending order. Calculate the sum of biggest and smallest age from A. If the sum was more than 18 then these two should form a team, otherwise remove the smaller one from A. Continue this algorithm until we reach $|A| = 0$ or $|A| = 1$.
I believe this algorithm is the optimal answer but I don't know how to prove it.