记录编号 |
20125 |
评测结果 |
AAAAA |
题目名称 |
[HAOI 2005]希望小学 |
最终得分 |
100 |
用户昵称 |
belong.zmx |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.001 s |
提交时间 |
2010-10-20 20:11:26 |
内存使用 |
0.12 MiB |
显示代码纯文本
program hopeschool;
type
node=record
girl,boy:word;
end;
var
i,j,k,n,a,b,c,d,e:word;
bb,gg:array[1..3]of word;
dist:array[1..30,1..30]of node;
x,y:array[1..30]of word;
procedure add_way(a,b,c,d:word);
begin
dist[a,b].boy:=c;
dist[a,b].girl:=d;
end;
begin
assign(input,'hopeschool.in');
reset(input);
assign(output,'hopeschool.out');
rewrite(output);
readln(n,bb[1],bb[2],bb[3],gg[1],gg[2],gg[3]);
for i:=1 to n do
read(x[i]);
for i:=1 to n do
read(y[i]);
for i:=1 to n do
for j:=1 to n do
if i<>j then
add_way(i,j,maxint,maxint)
else
add_way(i,j,0,0);
readln(k);
for i:=1 to k do
begin
read(a,b,c,d,e);
add_way(a,b,c*bb[1]+d*bb[2]+e*bb[3],c*gg[1]+d*gg[2]+e*gg[3]);
add_way(b,a,c*bb[1]+e*bb[2]+d*bb[3],c*gg[1]+e*gg[2]+d*gg[3]);
end;
for k:=1 to n do
for i:=1 to n do
if (dist[i,k].boy<maxint)or(dist[i,k].girl<maxint) then
for j:=1 to n do
if i<>j then
begin
if dist[i,k].boy+dist[k,j].boy<dist[i,j].boy then
dist[i,j].boy:=dist[i,k].boy+dist[k,j].boy;
if dist[i,k].girl*y[i]+dist[k,j].girl<dist[i,j].girl then
dist[i,j].girl:=dist[i,k].girl+dist[k,j].girl;
end;
b:=maxint;
for i:=1 to n do
begin
c:=0;
for j:=1 to n do
if i<>j then
c:=c+dist[j,i].boy*x[j]+dist[j,i].girl*y[j];
if c<b then
begin
b:=c;
a:=i;
end;
end;
writeln(a);
close(input);
close(output);
end.