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))
点赞 评论

相关推荐

中电45所 测试开发岗 可以解决北京户口,提供员工宿舍,早 8 晚 5(不过一般会加班到7-8点,周六一般也会去,面试官说的) 硕士
点赞 评论 收藏
转发
牛客网
牛客企业服务