21497_CelebritySpli

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

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

Pro.ID

21497

Title

Celebrity Split

Title链接

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

AC

0

Submit

1

Ratio

0.00%

时间&空间限制

  • Time Limit: 60000/30000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Jack and Jill have decided to separate and divide their property equally. Each of their N mansions has a value between 1,000,000 and 40,000,000 dollars. Jack will receive some of the mansions; Jill will receive some of the mansions; the remaining mansions will be sold, and the proceeds split equally.

    Neither Jack nor Jill can tolerate the other receiving property with higher total value. The sum of the values of the mansions Jack receives must be equal to the sum of the values of the mansions Jill receives. So long as the value that each receives is equal, Jack and Jill would like each to receive property of the highest possible value.

    Given the values of N mansions, compute the value of the mansions that must be sold so that the rest may be divided so as to satisfy Jack and Jill.

    Example

    Suppose Jack and Jill own 5 mansions valued at 6,000,000, 30,000,000, 3,000,000, 11,000,000, and 3,000,000 dollars. To satisfy their requirements, Jack or Jill would receive the mansion worth 6,000,000 and the other would receive both manstions worth 3,000,000 dollars. The mansions worth 11,000,000 and 30,000,000 dollars would be sold, for a total of 41,000,000 dollars. The answer is therefore 41000000.

    输入

    The input consists of a sequence of test cases. The first line of each test case contains a single integer N, the number of mansions, which will be no more than 24. This line is followed by N lines, each giving the value of a mansion. The final line of input contains the integer zero. This line is not a test case and should not be processed.

    输出

    Description

    Jack and Jill have decided to separate and divide their property equally. Each of their N mansions has a value between 1,000,000 and 40,000,000 dollars. Jack will receive some of the mansions; Jill will receive some of the mansions; the remaining mansions will be sold, and the proceeds split equally.

    Neither Jack nor Jill can tolerate the other receiving property with higher total value. The sum of the values of the mansions Jack receives must be equal to the sum of the values of the mansions Jill receives. So long as the value that each receives is equal, Jack and Jill would like each to receive property of the highest possible value.

    Given the values of N mansions, compute the value of the mansions that must be sold so that the rest may be divided so as to satisfy Jack and Jill.

    Example

    Suppose Jack and Jill own 5 mansions valued at 6,000,000, 30,000,000, 3,000,000, 11,000,000, and 3,000,000 dollars. To satisfy their requirements, Jack or Jill would receive the mansion worth 6,000,000 and the other would receive both manstions worth 3,000,000 dollars. The mansions worth 11,000,000 and 30,000,000 dollars would be sold, for a total of 41,000,000 dollars. The answer is therefore 41000000.

    Input

    The input consists of a sequence of test cases. The first line of each test case contains a single integer N, the number of mansions, which will be no more than 24. This line is followed by N lines, each giving the value of a mansion. The final line of input contains the integer zero. This line is not a test case and should not be processed.

    Output

    For each test case, output a line containing a single integer, the value of the mansions that must be sold so that the rest may be divided so as to satisfy Jack and Jill.

    Sample Input

    5
    6000000
    30000000
    3000000
    11000000
    3000000
    0

    Sample Output

    41000000

    Source

    样例输入

    5
    6000000
    30000000
    3000000
    11000000
    3000000
    0

    样例输出

    41000000

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部