Pagini recente » Cod sursa (job #1251695) | Cod sursa (job #285442) | Cod sursa (job #2253508) | Cod sursa (job #1404991) | Cod sursa (job #67571)
Cod sursa(job #67571)
const inf=maxlongint div 4;
var a,b:array[0..30000] of longint;
sd,min,x,y,n,i,j,k,l,m,max:longint;
begin
assign(input,'sate.in');
assign(output,'sate.out');
reset(input);
rewrite(output);
readln(n,m,x,y);
fillchar(a,n+1,0);
fillchar(b,n+1,0);
for i:=1 to m do
begin
read(k,l,min);
if a[l]-a[k]<>min then if a[l]-min>a[k] then begin
a[k]:=a[l]-min;
b[k]:=b[l];
end
else begin
a[l]:=a[k]+min;
b[l]:=k;
end;
end;
for sd:=1 to 12 do
begin
close(input);
reset(input);
ok:=true;
readln(n,m,x,y);
for i:=1 to m do
begin
read(k,l,min);
if a[l]-a[k]<>min then if a[l]-min>a[k] then begin
a[k]:=a[l]-min;
b[k]:=b[l]; ok:=false;
end
else begin
a[l]:=a[k]+min;
b[l]:=k; ok:=false;
end;
end;
if a[y]-a[x]>=max then max:=a[y]-a[x];
if ok then break;
end;
writeln(max);
close(input);
close(output);
end.