Milk Scheduling
Posted godrose
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Milk Scheduling相关的知识,希望对你有一定的参考价值。
题面:
思路:
代码:
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的主要内容,如果未能解决你的问题,请参考以下文章
洛谷P3093 [USACO13DEC]牛奶调度Milk Scheduling
P3093 [USACO13DEC]牛奶调度Milk Scheduling——贪心
[P3074 | USACO13FEB] Milk Scheduling | SPFA最长路 | 超级源点 + 超级汇点
P3093 [USACO13DEC]牛奶调度Milk Scheduling - 贪心+二叉堆