22811_Balloons

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

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

Pro.ID

22811

Title

Balloons

Title链接

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

AC

17

Submit

63

Ratio

26.98%

时间&空间限制

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

    As you know, balloons are handed out during this contest to teams as they solve problems. However, in the past this has sometimes presented challenging logistical problems.

    One contest hosting site maintained two rooms, A and B, each containing a supply of balloons. There were N teams attending the contest, each sitting in different locations, some being closer to room A, and others to room B. Given the number of balloons needed by each team and each teams distance from room A and room B, what is the minimum total possible distance that must be traveled by all balloons as they are delivered to their respective teams, assuming they are allocated in an optimal fashion from rooms A and B? For the purposes of this problem, assume that the contest staff were cheap and only bought one color of balloon.

    输入

    There will be several test cases in the data file. Each test case will begin with a line with three integers:   N A B, where N is the number of teams ( 1 ≤ N ≤ 1000 ), and A and B are the number of balloons in rooms A and B, respectively ( 0 ≤ A, B ≤ 10000 ).

    On each of the next N lines there will be three integers, representing information for each team:  K  DA  DB where K is the total number of balloons that this team will need, DA is the distance of this team from room A, and DB is this team's distance from room B ( 0 ≤ DA, DB ≤ 1000 ). You may assume that there are enough balloons -- that is, . The data file will end with a line with three 0s.

    输出

    Description

    As you know, balloons are handed out during this contest to teams as they solve problems. However, in the past this has sometimes presented challenging logistical problems.

    One contest hosting site maintained two rooms, A and B, each containing a supply of balloons. There were N teams attending the contest, each sitting in different locations, some being closer to room A, and others to room B. Given the number of balloons needed by each team and each teams distance from room A and room B, what is the minimum total possible distance that must be traveled by all balloons as they are delivered to their respective teams, assuming they are allocated in an optimal fashion from rooms A and B? For the purposes of this problem, assume that the contest staff were cheap and only bought one color of balloon.

    Input

    There will be several test cases in the data file. Each test case will begin with a line with three integers:   N A B, where N is the number of teams ( 1 ≤ N ≤ 1000 ), and A and B are the number of balloons in rooms A and B, respectively ( 0 ≤ A, B ≤ 10000 ).

    On each of the next N lines there will be three integers, representing information for each team:  K  DA  DB where K is the total number of balloons that this team will need, DA is the distance of this team from room A, and DB is this team's distance from room B ( 0 ≤ DA, DB ≤ 1000 ). You may assume that there are enough balloons -- that is, . The data file will end with a line with three 0s.

    Output

    For each test case, output a single integer, representing the minimum total distance that must be traveled to deliver all of the balloons. Count only the outbound trip, from A or B to the team. Don't count the distance that a runner must travel to return to room A or room B. Print each integer on its own line with no spaces.

    Do not print any blank lines between answers.

    Sample Input

    3 15 35
    10 20 10
    10 10 30
    10 40 10
    0 0 0

    Sample Output

    300

    Source

    样例输入

    3 15 35
    10 20 10
    10 10 30
    10 40 10
    0 0 0

    样例输出

    300

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部