eolymp
bolt
Try our new interface for solving problems
Problems

Tug of War

Tug of War

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 \textbf{1}; the total weight of the people on each team should be as nearly equal as possible. \InputFile The first line of input contains \textbf{n} the number of people at the picnic. \textbf{n} lines follow. The first line gives the weight of person \textbf{1}; the second the weight of person \textbf{2}; and so on. Each weight is an integer between \textbf{1} and \textbf{450}. There are at most \textbf{100} people at the picnic. \OutputFile Your output will be a single line containing \textbf{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.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
100
90
200
Output example #1
190 200
Source 2000 Waterloo local contest, September 30, Problem D