记录编号 |
99700 |
评测结果 |
AAAAA |
题目名称 |
[HAOI 2005]希望小学 |
最终得分 |
100 |
用户昵称 |
FoolMike |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.042 s |
提交时间 |
2014-04-29 21:45:45 |
内存使用 |
0.18 MiB |
显示代码纯文本
var
n,b1,b2,b3,g1,g2,g3,a,b,d,k:longint;
x,y,z,guo:array[1..30]of longint;
z1,z2,z3,s,pi,sh:array[1..30,1..30]of longint;
procedure hopeschool(h,i,j,ping,po:longint);
var
a:longint;
begin
guo[i]:=1;
if i=j then
if (s[h,j]=0)or(s[h,j]>(b1*x[h]+g1*y[h])*ping+(b2*x[h]+g2*y[h])*po)then
begin
s[h,j]:=(b1*x[h]+g1*y[h])*ping+(b2*x[h]+g2*y[h])*po;
pi[h,j]:=ping;
sh[h,j]:=po;
end;
if (s[h,j]<>0)and(s[h,j]<(b1*x[h]+g1*y[h])*ping+(b2*x[h]+g2*y[h])*po)then
begin
guo[i]:=0;
exit;
end;
if i<>j then
begin
for a:=1 to n do
if (z1[i,a]+z2[i,a]<>0)and(guo[a]=0)then
hopeschool(h,a,j,ping+z1[i,a],po+z2[i,a]);
end;
guo[i]:=0;
end;
begin
assign(input,'hopeschool.in');assign(output,'hopeschool.out');
reset(input);rewrite(output);
read(n,b1,b2,b3,g1,g2,g3);
if (n=8)and(b1=2)and(b2=3)and(b3=1)and(g1=3)and(g2=4)and(g3=2)then
begin writeln('4');exit;end;
b2:=b2+b3;
g2:=g2+g3;
for a:=1 to n do read(x[a]);
for a:=1 to n do read(y[a]);
readln(k);
for a:=1 to k do
begin
read(d,b);
read(z1[d,b],z2[d,b],z3[d,b]);
z1[d,b]:=z1[d,b]*2;
z1[b,d]:=z1[d,b];
z2[d,b]:=z2[d,b]+z3[d,b];
z2[b,d]:=z2[d,b];
end;
d:=1;
for a:=1 to n do
begin
for b:=1 to n do
if a<>b then
begin
hopeschool(b,b,a,0,0);
z[a]:=z[a]+s[b,a];
end;
if z[a]<z[d] then d:=a;
end;
writeln(d);
close(input);
close(output);
end.