记录编号 |
15236 |
评测结果 |
WWWWWWAAWWWWWWWWWWWW |
题目名称 |
溶液混合 |
最终得分 |
10 |
用户昵称 |
bing |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.128 s |
提交时间 |
2009-11-11 08:09:28 |
内存使用 |
0.15 MiB |
显示代码纯文本
program bing;
var
f1,f2:text;
a,b,max,min:array[1..50] of integer;
n,m:integer;
f:array[1..50,0..100] of real;
procedure init;
var
i,j:integer;
begin
assign(f1,'mix.in');reset(f1);
assign(f2,'mix.out');rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
for i:=1 to n do read(f1,b[i]);
read(f1,m);
for i:=1 to 50 do
for j:=0 to 100 do f[i,j]:=0;
for i:=1 to 50 do
begin
max[i]:=0;min[i]:=101;
end;
f[1,a[1]]:=b[1];
max[1]:=a[1];
min[1]:=a[1];
end;
procedure nb;
var
i,j,k,t1,t2:integer;
v1,v2,b1,b2:real;
begin
for i:=2 to n do
begin
if min[i-1]<a[i] then min[i]:=min[i-1] else min[i]:=a[i];
if max[i-1]>a[i] then max[i]:=max[i-1] else max[i]:=a[i];
for j:=min[i-1] to max[i-1] do
begin
if j<a[i] then
begin
v1:=f[i-1,j];v2:=b[i];
t1:=j;t2:=a[i];
end
else
begin
v1:=b[i];v2:=f[i-1,j];
t1:=a[i];t2:=j;
end;
for k:=t1 to t2 do
begin
b1:=abs(t2-k);
b2:=abs(t1-k);
if (b1=0)and(b2=0) then break;
if b1=0 then f[i,k]:=f[i-1,k]+v2;
if b2=0 then f[i,k]:=f[i-1,k]+v1;
if (b1<>0)and(b2<>0) then
begin
if v1/b2*b1>v2 then f[i,k]:=f[i-1,k]+v2+v2/b1*b2
else f[i,k]:=f[i-1,k]+v1+v1/b2*b1;
end;
end;
end;
end;
end;
begin
init;
nb;
writeln(f2,f[n,m]:0:5);
close(f1);close(f2);
end.