比赛 20091110 评测结果 WAWWWWAWWAWAWWWWWWWW
题目名称 溶液混合 最终得分 20
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-10 09:38:04
显示代码纯文本
program mix;
 const
   maxn = 50;
 var
   n:           longint;
   cy:          extended;
   tmp,ans,sum: extended;
   A,B,c:       array[1..maxn] of extended;




procedure init;
 var
   i:   longint;
 begin
   readln(n);
   for i :=1 to n do read(A[i]);
   for i :=1 to n do A[i] :=A[i]/100;
   for i :=1 to n do read(B[i]);
   readln(cy);  cy :=cy/100;
 end;

procedure sort;
 var
   temp:        extended;
   i,j:         longint;
 begin
   for i :=1 to n-1 do
       for j :=i+1 to n do
       if c[i] <c[j] then begin
          temp :=c[i]; c[i] :=c[j]; c[j] :=temp;
          end;
 end;



procedure main;
 var
   i:           longint;
   temp:        extended;
 begin
   for i :=1 to n do c[i] :=cy-A[i];
   for i :=1 to n do tmp :=tmp + c[i]*B[i];
   for i :=1 to n do sum :=sum + B[i];
   if tmp = 0
      then ans :=sum
      else begin
           sort;  ans :=sum;
           if tmp >0
              then begin
                   for i :=1 to n do begin
                       if tmp - c[i]*B[i] <=0 then begin
                          ans :=ans - tmp/c[i]; break;
                          end;
                       tmp :=tmp - c[i] *B[i];
                       ans :=ans - B[i];
                       end;
                   end
              else begin
                   for i :=1 to n shr 1 do begin
                       temp :=c[i]; c[i] :=c[n-i+1]; c[n-i+1] :=temp;
                       end;
                   for i :=1 to n do begin
                       if tmp - c[i]*B[i] >=0 then begin
                          ans :=ans - tmp/c[i]; break;
                          end;
                       tmp :=tmp - c[i]*B[i];
                       ans :=ans - B[i];
                       end;
                   end;
           end;

   writeln(ans:0:5);
 end;




begin
  assign(input,'mix.in');  reset(input);
  assign(output,'mix.out'); rewrite(output);
  init;
  main;
  close(input);  close(output);
end.