I. A-2 The Best Grouping Balance

    传统题 200ms 64MiB

A-2 The Best Grouping Balance

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

During the laboratary session, the teacher grouped all the students into pairs so they could help each other on their homework. The students' individual abilities are different, and the group ability is defined to be the sum of the ability values of the two students in that group. Now the teacher would like to have a grouping scheme that has the bestgrouping balance , that is, the difference between the maximum and minimum of all the group ability values is minimized.

Given the ability values of all the students, your job is to find this minimum difference.

输入格式

Each input file contains one test case. For each case, the first line gives a positive even number nn ( 2n1052\le n\le 10^5 ), which is the number of students. The next line gives nn numbers, representing the students' individual abilities (each an integer in the interval [1,108][1, 10^8] ). All the numbers in a line are separated by spaces.

输出格式

For each test case, output in a line the minimum of the difference between the maximum and minimum of all the group ability values, over all the possible grouping schemes.

题目示例数据

10
996 385 402 763 102 88 571 29 816 663
183

PAT2025春季重现赛

未参加
状态
已结束
规则
IOI
题目
11
开始于
2025-7-20 14:00
结束于
2025-7-20 17:30
持续时间
3.5 小时
主持人
参赛人数
46