比赛 20091110 评测结果 WAWWWAAAAAWAWAAAWWWW
题目名称 溶液混合 最终得分 50
用户昵称 ZhouZn1 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-10 11:49:14
显示代码纯文本
program mix;

var
        n,i,j,want:longint;
        a:array[1..50]of longint;
        b:array[1..50]of real;
        maxx:array[1..50]of longint;
        ans:real;
        v:array[1..50]of boolean;
procedure init;
begin
        assign(input,'mix.in');
        reset(input);
        assign(output,'mix.out');
        rewrite(output);
        readln(n);
        fillchar(v,sizeof(v),0);
        j:=0;
        for i:=1 to n do
        read(a[i]);
        readln;
        for i:=1 to n do
        begin
        read(b[i]);
        end;
        readln;
        ans:=0;
        readln(want);
        for i:=1 to n do if a[i]=want then
        begin
        ans:=ans+b[i];
        v[i]:=true;
        end;
end;

procedure closef;
begin
        close(input);
        close(output);
end;

procedure main;
var
        sum:longint;
        k:real;
begin
        for i:=1 to n do  if not(v[i]) then
        begin
                for j:=1 to n do
                 if not(v[j]) then
                  if i<>j then
                   if ((a[i]>want)and(a[j]<want))or((a[i]<want)and(a[j]>want))  then
                   begin
                        k:=abs(a[j]-want)/abs(a[i]-want);
                        if b[i]=b[j]*k then
                        begin
                                ans:=ans+b[i]+b[j];
                                b[i]:=0;
                                b[j]:=0;
                        end;
                        if b[i]>b[j]*k then
                        begin
                                ans:=ans+b[j]*k+b[j];
                                b[i]:=b[i]-b[j]*k;
                                b[j]:=0;
                        end;
                        if b[i]<b[j]*k then
                        begin
                                ans:=ans+b[i]/k+b[i];
                                b[j]:=b[j]-b[i]/k;
                                b[i]:=0;
                        end;
                   end;
        end;
        writeln(ans:0:5);
end;
begin
        init;
        main;
        closef;
end.