跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0501. Problem D: Tug of War

    ID: 507 传统题 10000ms 128MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>待分类整理状态难度待定难度共享题库高校与竞赛共享题英文题面题目来源题面语言

Problem D: Tug of War

题目描述

Problem D: 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 1; the total weight of the people on each team should be as nearly equal as possible.

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.

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.

样例 1

输入

3
100
90
200

输出

190 200

题目来源:fps-zhblue-waterloo-000930.xml;FPS 共享题包,题包内第 4 题。保留原作者与原赛事署名。