poj 2576
来源:互联网 发布:安徽用友软件代理商 编辑:程序博客网 时间:2024/05/21 22:25
Tug of War
Time Limit: 3000MS Memory Limit: 65536KTotal Submissions: 6615 Accepted: 1658
Description
A tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must be on one team or the other; the number of people on the two teams must not differ by more than 1; the total weight of the people on each team should be as nearly equal as possible.
Input
The first line of input contains n the number of people at the picnic. n lines follow. The first line gives the weight of person 1; the second the weight of person 2; and so on. Each weight is an integer between 1 and 450. There are at most 100 people at the picnic.
Output
Your output will be a single line containing 2 numbers: the total weight of the people on one team, and the total weight of the people on the other team. If these numbers differ, give the lesser first.
Sample Input
3 100 90 200Sample Output
190 200Source
Waterloo local 2000.09.30
分析:用了DP,不过貌似有O(n^2)的解法,忘记了。。。。哪个神牛指教一下