POJ1949

Chores

 

#include <stdio.h>

long endTime[10002];
long m,n;

void Solve()
{
    
long cost,tt,max,i;//cost表示第i次所需的时间
    long theFinal;//最后输出数
    scanf("%ld%ld",&cost,&m);
    theFinal
=endTime[1= cost;//第一个无可依赖
    for(i = 2; i <= n; i++)
    
{
        scanf(
"%ld%ld",&cost,&m);
        max 
= 0;
        
while(m--)//寻找此依赖的最大时间
        {
            scanf(
"%ld",&tt);
            
if(max < endTime[tt])
                max 
= endTime[tt];
        }

        endTime[i] 
= max + cost;
        
if(endTime[i] > theFinal)theFinal = endTime[i];
    }

    printf(
"%ld\n",theFinal);
}

int main()
{
    
while(scanf("%ld",&n)!=EOF)
        Solve();
    
return 0;
}

posted on 2009-02-27 20:35  Xredman  阅读(196)  评论(0编辑  收藏  举报

导航