QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 64 MB 總分: 100

#18087. 智商

统计

有 $2n$ 名新生参加了程序设计竞赛训练。每名学生都有一个 IQ 值:第 $i$ 名学生的 IQ 为 $a_i$。

教练希望将学生两两分组。每支队伍的队伍 IQ 等于该队两名成员的 IQ 之和。例如,如果一支队伍由学生 $i$ 和 $j$ 组成,则该队的队伍 IQ 为 $a_i + a_j$。如果一支队伍的队伍 IQ 大于另一支队伍,则称该队伍更强。

教练认为,如果最强队伍和最弱队伍之间的队伍 IQ 差值尽可能小,训练效果会更好。请帮助教练确定一个最小值 $A$,使得可以通过分组,让最强队伍和最弱队伍之间的队伍 IQ 差值等于 $A$。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 100$)。

第二行包含 $2n$ 个整数,其中第 $i$ 个整数表示第 $i$ 名学生的 IQ $a_i$ ($1 \le a_i \le 200, 1 \le i \le 2n$)。

输出格式

输出使得分组可行的情况下,最强队伍与最弱队伍之间队伍 IQ 差值的最小值 $A$。

样例

样例输入 1

3
100 100 89 140 102 150

样例输出 1

38

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.