weight,num_of_goods=input().split(' ')
weight,num_of_goods=int(weight),int(num_of_goods)
each_weight=input().split(' ')
for i in range(len(each_weight)):
each_weight[i]=int(each_weight[i])
values=input().split(' ')
for i in range(len(values)):
values[i]=int(values[i])
res=[]
def sol_2(W,V,weight,result):
global res
if weight<0:
return 0
if len(W)==1:
if weight-W[0]<0:
result=result
else:
result+=V[0]
res.append(result)
else:
#要
sol_2(W[1:],V[1:],weight-W[0],result+V[0])
#不要
sol_2(W[1:],V[1:],weight,result)
sol_2(each_weight,values,weight,0)
print("%.1f"%(max(res)*0.1))