Pagini recente » Cod sursa (job #2795642) | Cod sursa (job #2537233) | Cod sursa (job #1319857) | Cod sursa (job #2494588) | Cod sursa (job #324131)
Cod sursa(job #324131)
program reteta;
var a,v,val:array[0..20] of integer;
x,y,i,j,n,m:integer;
s:longint;
t:int64;
suma,nr_final:real;
f,g:text;
procedure calc(nr:integer);
var i,j:integer;
max:real;
begin
suma:=0;
for i:=0 to m do
if (nr and (1 shl i)<>0) then
begin
max:=0;
for j:=0 to n do
if (a[i] and (1 shl j)<>0) then
max:=max+v[j];
max:=max/val[i];
suma:=suma+max;
end;
end;
begin
assign(f,'reteta.in');
assign(g,'reteta.out');
reset(f);
rewrite(g);
read(f,n,m);
for i:=0 to m-1 do
begin
read(f,val[i]);
read(f,x);
a[i]:=0;
for j:=1 to x do
begin
read(f,y);
a[i]:=a[i]+1 shl (y-1);
end;
end;
for i:=0 to n-1 do
read(f,v[i]);
nr_final:=20000;
for i:=1 to (1 shl m) do
begin
s:=0;
for j:=0 to m-1 do
if i and (1 shl j)<>0 then
s:=s xor a[j];
if (s=1 shl n -1) then
begin
calc(i);
if suma<nr_final then nr_final:=suma;
end;
end;
t:=trunc(suma);
if t mod 10=5 then writeln(g,t div 10,'.5')
else writeln(g,t div 10,'.0');
close(f);
close(g);
end.