using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int[] InDeg = new int[N]; for(int i=0;i x !=0).Aggregate(true, (b,y) => b&y ) ); int[] ENT = new int[N]; // Earliest Node Time for(int i=0;i Q = new Queue(N); Q.Enqueue(0); while(Q.Count>0){ var now = Q.Dequeue(); foreach(var e in E[now]){ InDeg[B[e]]--; if(InDeg[B[e]] == 0){ Q.Enqueue(B[e]); } ENT[B[e]] = Math.Max(ENT[B[e]], ENT[now] + C[e]); } } Debug.Assert( InDeg.Select(x => x == 0).Aggregate(true, (b,y) => b&y ) ); int[] OutDeg = new int[N]; int[] LNT = new int[N]; // Latest Node Time for(int i=0;i(N); Q.Enqueue(N-1); while(Q.Count>0){ var now = Q.Dequeue(); foreach(var xe in XE[now]){ OutDeg[A[xe]]++; if(OutDeg[A[xe]] == E[A[xe]].Count){ Q.Enqueue(A[xe]); } LNT[A[xe]] = Math.Min(LNT[A[xe]], LNT[now] - C[xe]); } } Debug.Assert( OutDeg[N-1] == 0 ); Debug.Assert( OutDeg.Zip(E,(n,p) => n == p.Count).Aggregate(true, (b,y) => b&y ) ); Debug.Assert( ENT.Zip(LNT,(e,l) => e > l).Count( b => b ) == 0); //Console.WriteLine(String.Join(" ",ENT)); //Console.WriteLine(String.Join(" ",LNT)); int marginPersonCount = ENT.Zip(LNT,(e,l) => l > e).Count( b => b ); Console.WriteLine("{0} {1}/{2}",ENT[N-1],marginPersonCount,N); } int N,M; List[] E; List[] XE; int[] A,B,C; public Sol(){ // read input int[] d; d = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); N = d[0]; M = d[1]; E = new List[N]; for(int i=0;i(); XE = new List[N]; for(int i=0;i(); A = new int[M]; B = new int[M]; C = new int[M]; for(int i=0;i