比赛 |
20101116 |
评测结果 |
AAWWWTEEEA |
题目名称 |
城市 |
最终得分 |
30 |
用户昵称 |
1102 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-16 10:09:50 |
显示代码纯文本
program xxxx;
var a1,a2,a3,n,m,u,v,s,i,j,k,max:longint;
f:array[1..3500,1..3500,0..1] of longint;
a:array[1..10000] of longint;
function maxx(x,y:longint):longint;
begin
if x>y then
maxx:=x
else
maxx:=y;
end;
begin
assign(input,'cost.in');
reset(input);
assign(output,'cost.out');
rewrite(output);
read(n,m,u,v,s);
max:=maxlongint;
for i:=1 to n do
read(a[i]);
for i:=1 to n do
for j:=1 to n do
begin
f[i,j,0]:=max;
f[i,j,1]:=max;
end;
for i:=1 to m do
begin
read(a1,a2,a3);
f[a1,a2,0]:=a3;
f[a1,a2,1]:=maxx(a[a1],a[a2]);
f[a2,a1,0]:=a3;
f[a2,a1,1]:=f[a1,a2,1];
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (f[i,k,0]<max)and(f[j,k,0]<max) then
if f[i,k,0]+f[j,k,0]<=s then
if maxx(f[i,k,1],f[j,k,1])<f[i,j,1] then
begin
f[i,j,1]:=maxx(f[i,k,1],f[j,k,1]);
f[i,j,0]:=f[i,k,0]+f[j,k,0];
end;
if f[u,v,1]<max then
write(f[u,v,1])
else
write('-1');
close(input);
close(output);
end.