시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 64 | 53 | 43 | 84.314% |
The Resistance is assigning pilots to new two-person X-wing Starfighters. General Leia has assigned you the task of putting teams together for the Red Squadron. Every pilot must be placed on exactly one 2- person team, and there are an even number of pilots. However, you would like to maintain a high skill level for each team by making sure that each of the teams has some minimum total rating. We define the total rating of a team to be the sum of the ratings of both pilots on the team.
You must determine the maximum value, X, such that you can form teams, each of which have a total rating greater than or equal to X.
The first line of input contains a single positive integer n (1 ≤ 105, n is even), the number of pilots who volunteered for Red Squadron. Each of the following n lines contains one single integer si (1 ≤ si ≤ 106), the rating of pilot i.
Print, on a single line, the maximum value, X, such that you can form teams where every team has a total rating greater than or equal to X.
4 2 1 3 5
5