比赛 20100324 评测结果 EEEEE
题目名称 希望小学 最终得分 0
用户昵称 Achilles 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-03-24 20:42:25
显示代码纯文本
program hopeschool;
var
  i,k,n,b1,b2,b3,g1,g2,g3,min,aa,bb,s1,s2,s3,ans,minr:longint;
  tab:array[1..30,1..30]of record
    p:boolean;
    r1,r2,r3:longint;
  end;
  b,g:array[1..30]of longint;
procedure find(last,s,l1,l2,l3:longint);
var
  i:longint;
begin
  for i:=1 to n do
  begin
    if (tab[i,s].p=true)and(i<>last) then begin
      l1:=l1+tab[i,s].r1;
      l2:=l2+tab[i,s].r2;
      l3:=l3+tab[i,s].r3;
      ans:=ans+b1*b[i]*l1+b2*b[i]*l2+b3*b[i]*l3+g1*g[i]*l1+g2*g[i]*l2+g3*g[i]*l3;
      find(s,i,l1+tab[i,s].r1,l2+tab[i,s].r2,l3+tab[i,s].r3);
    end;
  end;
end;
begin
  assign(input,'hopeschool.in');
  assign(output,'hopeschool.out');
  reset(input);
  rewrite(output);
  readln(n,b1,b2,b3,g1,g2,g3);
  min:=2147483647;
  for i:=1 to n do
    for k:=1 to n do
      tab[i,k].p:=false;
  for i:=1 to n do
    read(b[i]);
  readln;
  for i:=1 to n do
    read(g[i]);
  readln;
  readln(k);
  for i:=1 to k do
  begin
    readln(aa,bb,s1,s2,s3);
    tab[aa,bb].p:=true;
    tab[aa,bb].r1:=s1;
    tab[aa,bb].r2:=s2;
    tab[aa,bb].r2:=s3;
    tab[bb,aa].p:=true;
    tab[bb,aa].r1:=s1;
    tab[bb,aa].r2:=s3;
    tab[bb,aa].r2:=s2;
  end;
  for i:=1 to n do
  begin
    ans:=0;
    find(0,i,0,0,0);
    if ans<min then begin
      min:=ans;
      minr:=i;
    end;
  end;
  writeln(minr);
  close(input);
  close(output);
end.