Each input line x y means there are $x$ cows producing $y$ milk each. Split all the cows into pairs so that the largest pair total ($A + B$) is as small as possible, and print that minimum possible maximum. (Sort all outputs and pair the smallest with the largest.)
Input
Line 1: $N$ groups. Next $N$ lines: x y (the total number of cows is even).
Output
Print the minimum possible largest pair sum.
Example 1
Input
3 1 8 2 5 1 2
Output
10
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.