首页 > 其他 > 详细

Milk Scheduling

时间:2018-10-04 14:28:49      阅读:141      评论:0      收藏:0      [点我收藏+]

题面:

技术分享图片

思路:

 

代码:

uses math;
var ans,n,m,tot,x,y,i,j:longint;
 next,last,tail:array[0..100005] of longint;
  t,c,d:array[0..10005] of longint;
   f:Array[0..10005] of boolean;

procedure add(x,y:longint);
begin
 inc(tot);
 next[tot]:=y;
 last[tot]:=tail[x];
 tail[x]:=tot;
end;

procedure dfs(x,y:longint);
var cc:longint;
begin
 c[x]:=max(c[x],y+t[x]);
 dec(d[x]);
 if d[x]=0 then
  begin
   cc:=tail[x];
   while (cc>0) do
    begin
     dfs(next[cc],c[x]);
     cc:=last[cc];
    end;
  end;
end;

begin

assign(input,‘msched.in‘);
reset(input);
assign(output,‘msched.out‘);
rewrite(output);

read(n,m);
for i:=1 to n do read(t[i]);
for i:=1 to m do begin read(x,y); add(x,y); f[y]:=true; inc(d[y]); end;

for i:=1 to n do
 if not f[i] then
  begin
   d[i]:=1;
   dfs(i,0);
  end;

for i:=1 to n do ans:=max(ans,c[i]);
writeln(ans);

close(input);close(output);
end.

 

Milk Scheduling

原文:https://www.cnblogs.com/godrose/p/9742127.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!