Farmer John finds that his cows are each easier to milk when they have another cow nearby for moral support. He therefore wants to take hisMcows and partition them intoM/2pairs. Each pair of cows will then be ushered off to a separate stall in the barn for milking. The milking in each of theseM/2stalls will take place simultaneously. To make matters a bit complicated, each of Farmer John's cows has a different milk output. If cows of milk outputsAandBare paired up, then it takes a total ofA+Bunits of time to milk them both. Please help Farmer John determine the minimum possible amount of time the entire milking process will take to complete, assuming he pairs the cows up in the best possible way.
Farmer John finds that his cows are each easier to milk when they have another cow nearby for moral support. He therefore wants to take his M cows (M≤1,000,000,000, M even) and partition them into M/2 pairs. Each pair of cows will then be ushered off to a separate stall in the barn for milking. The milking in each of these M/2 stalls will take place simultaneously. To make matters a bit complicated, each of Farmer John's cows has a different milk output. If cows of milk outputs A and B are paired up, then it takes a total of A+B units of time to milk them both. Please help Farmer John determine the minimum possible amount of time the entire milking process will take to complete, assuming he pairs the cows up in the best possible way.