#K75622. Maximum Minimum Pair Efficiency
Maximum Minimum Pair Efficiency
Maximum Minimum Pair Efficiency
You are given a team of workers with their individual efficiencies. Your task is to form pairs of workers such that the efficiency of a pair is defined as the sum of the efficiencies of the two workers. However, you want to maximize the minimum pair efficiency among all pairs. In other words, among all possible pairings, choose the one where the smallest pair sum is as large as possible.
Formally, if a pair consists of two workers with efficiencies \(a\) and \(b\), the pair efficiency is \(a+b\). When you form \(\frac{n}{2}\) pairs (where \(n\) is even) by pairing workers, let \(E_i\) be the efficiency of the \(i\)-th pair. You must determine the maximum possible value of \(\min\{E_1, E_2, \dots, E_{n/2}\}\) by choosing an optimal pairing strategy.
The standard approach is to sort the list of efficiencies and then pair the smallest and largest, the second smallest and second largest, and so on. This strategy ensures that the minimum sum among all pairs is maximized.
inputFormat
The input is read from standard input (stdin) and can be in two formats depending on the test case.
- If the input starts with a single test case, the first line contains an integer n (which is even) denoting the number of workers. The second line contains n space-separated integers representing the efficiencies of the workers.
- If the input contains multiple test cases, the first line contains an integer T denoting the number of test cases. For each test case, the first line is an integer n (even) and the next line contains n space-separated integers.
Constraints: You may assume that \(1 \leq n \leq 10^5\) and each efficiency is a positive integer.
outputFormat
For each test case, output a single line on standard output (stdout) containing the maximum possible minimum pair efficiency achievable. If there are multiple test cases, the outputs should be in the same order as the corresponding inputs.
## sample1
4
1 3 5 5
6
</p>