比赛 20091110 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 溶液混合 最终得分 100
用户昵称 .Xmz 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-10 11:13:08
显示代码纯文本
program xmz;
var
f1,f2:text;
c,c1:array[0..50]of longint;
v,v1:array[0..50]of real;
a,t,n,b,cc:longint;
tr,min,s,vs:real;
procedure pei(i,j:longint);
begin
if v1[i]/abs(c1[j])>v1[j]/abs(c1[i]) then
 begin
 vs:=vs+v1[j]+v1[j]/abs(c1[i])*abs(c1[j]);
 v1[i]:=v1[i]-v1[j]/abs(c1[i])*abs(c1[j]);
 v1[j]:=0;
 end
else
 begin
  vs:=vs+v1[i]+v1[i]/abs(c1[j])*abs(c1[i]);
  v1[j]:=v1[j]-v1[i]/abs(c1[j])*abs(c1[i]);
 v1[i]:=0;
 end;
end;
begin
 assign(f1,'mix.in');assign(f2,'mix.out');
 reset(f1);rewrite(f2);
 read(f1,n);
 for a:=1 to n do
  read(f1,c[a]);
 for a:=1 to n do
  read(f1,v[a]);
 read(f1,cc);
 for a:=1 to n do
  for b:=a+1 to n do
   if c[b]<c[a] then
   begin
    t:=c[a];c[a]:=c[b];c[b]:=t;
    tr:=v[a];v[a]:=v[b];v[b]:=tr;
   end;
 for a:=1 to n do
  c[a]:=c[a]-cc;

 for a:=1 to n do
 begin
  v1[a]:=v[a];
  c1[a]:=c[a];
 end;
 t:=0;
 repeat
 min:=999999;
 inc(t);
 for a:=1 to n do
  if (c[a]*c[t]<0)and(v1[t]>0)and(v1[a]>0) then pei(a,t);
 until (c[t+1]>0)or(t=n);
 s:=vs;
  for a:=1 to n do
 begin
  v1[a]:=v[a];
 end;
 t:=n+1;vs:=0;
 repeat
 min:=999999;
 dec(t);
 for a:=n downto 1 do
  if (c[a]*c[t]<0)and(v1[t]>0)and(v1[a]>0) then pei(a,t);
 until (c[t-1]<0)or(t=1);
 if vs>s then s:=vs;
 for a:=1 to n do
  if c[a]=0 then s:=s+v[a];
  writeln(f2,s:0:5);
 close(f1);close(f2);
end.