Cod sursa(job #735993)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 17 aprilie 2012 17:24:00
Problema Distante Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.59 kb
Program distante2;
 var sol:array [1..50001] of longint;
    i,j,n,m,t,a,b,c,s:longint;
    ok:boolean;
    fi,fo:text;
begin
 assign(fi,'distante.in');
  assign(fo,'distante.out');
 reset(fi); rewrite(fo);
 readln(fi,t);
  for i:=1 to t do begin
   ok:=true; readln(fi,n,m,s);
    for j:=1 to n do read(fi,sol[j]); if sol[s]<>0 then ok:=false; readln(fi);
   for j:=1 to m do begin
                     readln(fi,a,b,c);
                      if sol[a]+c<sol[b] then ok:=false;
                     end;
   if ok then writeln(fo,'DA') else writeln(fo,'NU');
   end;
  close(fo);
end.