問題一覧 > 通常問題

No.3697 Balancing Skill

レベル : / AI推定難易度 : 1475 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 29
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 5885 / 自分の提出
問題文最終更新日: 2026-08-27 01:09:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
チーム機能テストコンテスト (順位表) の他の問題:

Problem Statement

There are $N$ participants, and the skill value of participant $i$ is $a_i$. $N$ is even.

When all participants are divided into $2$ teams of exactly $N/2$ people each, find the minimum possible value of the absolute difference between the total skill values of the $2$ teams.

Input

$N$
$a_1\ a_2\ \cdots\ a_N$

$2 \le N \le 40$
$N$ is even
$1 \le a_i \le 10^9$
All inputs are integers

Output

Output the minimum absolute difference between the total skill values. Print a newline at the end.

Sample

Sample 1
Input
4
1 3 4 5
Output
1

If divided into $\{1, 5\}$ and $\{3, 4\}$, the totals are $6$ and $7$, and the difference is $1$. It cannot be made smaller than this.

Sample 2
Input
6
10 10 10 10 10 10
Output
0

Since all skill values are the same, the difference is $0$ no matter how they are divided.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。