21430_TugofWar

2022-5-16 18:19| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505256393199-Problem List-采集的数据-后羿采集器.html

Pro.ID

21430

Title

Tug of War

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21430

AC

67

Submit

252

Ratio

26.59%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    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.

    输出

    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
    200

    Sample Output

    190 200

    Source

    样例输入

    3
    100
    90
    200

    样例输出

    190 200

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部