21299_ClassSchedule

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

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

Pro.ID

21299

Title

Class Schedule

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    At Fred Hacker's school, there are T × C classes, divided into C catagories of T classes each. The day begins with all the category 1 classes being taught simultaneously. These all end at the same time, and then all the category 2 classes are taught, etc. Fred has to take exactly one class in each category. His goal is to choose the set of classes that will minimize the amount of "energy'' required to carry out his daily schedule.

    The energy requirement of a schedule is the sum of the energy requirement of the classes themselves, and energy consumed by moving from one class to the next through the schedule.

    More specifically, taking the j-th class in the i-th category uses Eij units of energy. The rooms where classes take place are located at integer positions (ranging from 0 toL) along a single hallway. The j-th class in the i-th category is located at position Pij. Fred starts the day at position 0, moves from class to class, according to his chosen schedule, and finally exits at locationL. Moving a distancedusesdunits of energy.

    输入

    The first line of the input is Z ≤ 20 the number of test cases. This is followed by Z test cases. Each test case begins with three space-separated integers: C, T, and L. Each of the following C×T lines gives, respectively, the location and energy consumption of a class. The first T lines represent the classes of category 1, the next T lines represent the classes of category 2, and so on. No two classes in the same category will have the same location.

    1 ≤ C ≤ 25

    1 ≤ T ≤ 1000

    1 ≤ L ≤ 1,000,000

    1 ≤ Eij ≤ 1,000,000

    0 ≤ Pij ≤ L

    输出

    Description

    At Fred Hacker's school, there are T × C classes, divided into C catagories of T classes each. The day begins with all the category 1 classes being taught simultaneously. These all end at the same time, and then all the category 2 classes are taught, etc. Fred has to take exactly one class in each category. His goal is to choose the set of classes that will minimize the amount of "energy'' required to carry out his daily schedule.

    The energy requirement of a schedule is the sum of the energy requirement of the classes themselves, and energy consumed by moving from one class to the next through the schedule.

    More specifically, taking the j-th class in the i-th category uses Eij units of energy. The rooms where classes take place are located at integer positions (ranging from 0 toL) along a single hallway. The j-th class in the i-th category is located at position Pij. Fred starts the day at position 0, moves from class to class, according to his chosen schedule, and finally exits at locationL. Moving a distancedusesdunits of energy.

    Input

    The first line of the input is Z ≤ 20 the number of test cases. This is followed by Z test cases. Each test case begins with three space-separated integers: C, T, and L. Each of the following C×T lines gives, respectively, the location and energy consumption of a class. The first T lines represent the classes of category 1, the next T lines represent the classes of category 2, and so on. No two classes in the same category will have the same location.

    1 ≤ C ≤ 25

    1 ≤ T ≤ 1000

    1 ≤ L ≤ 1,000,000

    1 ≤ Eij ≤ 1,000,000

    0 ≤ Pij ≤ L

    Output

    For each input instance, the output will be a single integer on a line by itself which is the minimum possible energy of a schedule satisfying the constraints.

    Sample Input

    1
    3 2 5
    2 1
    3 1
    4 1
    1 3
    1 4
    3 2

    Sample Output

    11

    Hint

    Fred must take 3 classes every day, and for each he has 2 choices. The hall has length 5. His first possible class is located at position 2 and will take 1 unit of energy each day, etc.

    Here is one way to obtain the minimum energy:

    Go to the class at location 2. Energy used: 3

    Next, go to the class at location 4. Energy used: 6

    Then go to the class at location 3. Energy used: 9

    Finally, leave the school at location 5. Energy used: 11

    Source

    样例输入

    1
    3 2 5
    2 1
    3 1
    4 1
    1 3
    1 4
    3 2

    样例输出

    11

    提示

    Fred must take 3 classes every day, and for each he has 2 choices. The hall has length 5. His first possible class is located at position 2 and will take 1 unit of energy each day, etc.

    Here is one way to obtain the minimum energy:

    Go to the class at location 2. Energy used: 3

    Next, go to the class at location 4. Energy used: 6

    Then go to the class at location 3. Energy used: 9

    Finally, leave the school at location 5. Energy used: 11


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部