当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3017:Treasure Division

题目描述
Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts.

输入解释
Input contains multiple cases.Test cases are separated by several blank lines.

Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i.
输出解释
For each case,output the least difference that could be found in one fairest division.
输入样例
3
2 2 4
4
1 2 3 6
输出样例
0
2

提示

In sample 1,we can divide the 3 gold coins into {1,2},{3},
their difference is 0.
In sample 2,we can divide the 4 gold coins into {1,4},{2,3},
their difference is 2,which is also the least difference that could be made.

来自杭电HDUOJ的附加信息
Recommend gaojie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3017

最后修改于 2020-10-25T22:59:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)