No.3697 Balancing Skill
タグ : / 解いたユーザー数 29
作問者 :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。