22119_DependenciesamongJobs

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

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

Pro.ID

22119

Title

Dependencies among Jobs

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    As everybody knows, our staffs need to do a lot of jobs to prepare for ZQUCPC. But I bet you can not image how terrible to arrange the jobs. We know, sometimes there are dependencies among the jobs. We say job 2 depends on job 1 that means before starting job 1 we must finish job 2. We assume that there is only one job processing in one moment, and any job is dependent on no more than ten jobs.

    When we make up a jobs’ schedule, we should check whether it is valid. Now, your task is to find out the earliest finish time of some jobs.

    输入

    Input will contain several test cases. The first line of each test case contains two integer numbers N ( 0 <= N <= 10,000 ) and M. The jobs are numbered from 1 to N. You need to calculate the earliest finish time of the job M. And then, the following N lines describe jobs. The first line is corresponding the job 1, second line is corresponding the job 2 and so on.

    Each job’s describing line contains several positive integer numbers. The numbers are separated by spaces. The first one of the ith line shows the time ( <= 100 ) that ith job cost. The rest of numbers of the ith line are the jobs on which the job I depends.

    N=0 indicate the end of input file. We guaranteed there is no circle on dependency.

    输出

    Description

    As everybody knows, our staffs need to do a lot of jobs to prepare for ZQUCPC. But I bet you can not image how terrible to arrange the jobs. We know, sometimes there are dependencies among the jobs. We say job 2 depends on job 1 that means before starting job 1 we must finish job 2. We assume that there is only one job processing in one moment, and any job is dependent on no more than ten jobs.

    When we make up a jobs’ schedule, we should check whether it is valid. Now, your task is to find out the earliest finish time of some jobs.

    Input

    Input will contain several test cases. The first line of each test case contains two integer numbers N ( 0 <= N <= 10,000 ) and M. The jobs are numbered from 1 to N. You need to calculate the earliest finish time of the job M. And then, the following N lines describe jobs. The first line is corresponding the job 1, second line is corresponding the job 2 and so on.

    Each job’s describing line contains several positive integer numbers. The numbers are separated by spaces. The first one of the ith line shows the time ( <= 100 ) that ith job cost. The rest of numbers of the ith line are the jobs on which the job I depends.

    N=0 indicate the end of input file. We guaranteed there is no circle on dependency.

    Output
    For each test case you should output one line, and just one number in this line. The number is the earliest finishing time of job M.
    Sample Input

    2 2

    3

    2 1

    3 3

    3

    2 1

    4 1 2

    0

    Sample Output

    5

    9

    Source

    样例输入

    2 2

    3

    2 1

    3 3

    3

    2 1

    4 1 2

    0

    样例输出

    5

    9

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部