21559_BaleShare

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

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

Pro.ID

21559

Title

Bale Share

Title链接

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

AC

9

Submit

21

Ratio

42.86%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Farmer John has just received a new shipment of N (1 ≤ N ≤ 20) bales of hay, where bale i has size Si (1 ≤ Si ≤ 100).  He wants to divide the bales between his three barns as fairly as possible.

    After some careful thought, FJ decides that a "fair" division of the hay bales should make the largest share as small as possible.  That is, if B1, B2, and B3 are the total sizes of all the bales placed in barns 1, 2, and 3, respectively (where B1B2B3), then FJ wants to make B1 as small as possible.

    For example, if there are 8 bales in these sizes:

    2 4 5 8 9 14 15 20

    A fair solution is

    Barn 1: 2 9 15   B1 = 26

    Barn 2: 4 8 14   B2 = 26

    Barn 3: 5 20      B3 = 25

    Please help FJ determine the value of B1 for a fair division of the hay bales.

    输入

    * Line 1: The number of bales, N.

    * Lines 2..1+N: Line i+1 contains Si, the size of the i-th bale.

    输出

    Description

    Farmer John has just received a new shipment of N (1 ≤ N ≤ 20) bales of hay, where bale i has size Si (1 ≤ Si ≤ 100).  He wants to divide the bales between his three barns as fairly as possible.

    After some careful thought, FJ decides that a "fair" division of the hay bales should make the largest share as small as possible.  That is, if B1, B2, and B3 are the total sizes of all the bales placed in barns 1, 2, and 3, respectively (where B1B2B3), then FJ wants to make B1 as small as possible.

    For example, if there are 8 bales in these sizes:

    2 4 5 8 9 14 15 20

    A fair solution is

    Barn 1: 2 9 15   B1 = 26

    Barn 2: 4 8 14   B2 = 26

    Barn 3: 5 20      B3 = 25

    Please help FJ determine the value of B1 for a fair division of the hay bales.

    Input

    * Line 1: The number of bales, N.

    * Lines 2..1+N: Line i+1 contains Si, the size of the i-th bale.

    Output

    * Line 1: Please output the value of B1 in a fair division of the hay bales.

    Sample Input

    8
    14
    2
    5
    15
    8
    9
    20
    4

    Sample Output

    26

    Source

    样例输入

    8
    14
    2
    5
    15
    8
    9
    20
    4

    样例输出

    26

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部