#C7693. Maximize the Minimum Sum
Maximize the Minimum Sum
Maximize the Minimum Sum
You are given two arrays A and B of length N. Your task is to choose a permutation P of indices for array B such that when you form a new array C by computing
\( C[i] = A[i] + B[P[i]] \) for \(0 \le i < N\),
the minimum element of C is as large as possible. In other words, you want to maximize \( \min(C) \).
Input format: The input consists of three lines. The first line is an integer N, which represents the number of elements in the arrays. The second line contains N space-separated integers representing the array A. The third line contains N space-separated integers representing the array B.
Output format: Output a single integer, the maximum possible value of \( \min(C) \) given the optimal permutation P.
Hint: A greedy strategy of sorting A in ascending order and B in descending order will yield the optimal result.
inputFormat
The first line contains an integer N.
The second line contains N space-separated integers, the elements of array A.
The third line contains N space-separated integers, the elements of array B.
outputFormat
Output a single integer: the maximum possible value of the minimum element of array C.
## sample3
1 3 5
2 4 6
7
</p>