-->
当前位置:首页 > 题库

PROGRAMMING:Xiaoyu's combat power

Luz5年前 (2021-05-10)题库437
Courage is very important in marching, but the combat power increased by good equipment is more important
Xiaoyu has $$n $$weapons. The attack power of each weapon is $$AI $$, and the weight is $$Bi $$
Now Xiaoyu has to choose $$k $$weapons to maximize the sum of attack power / weight of these weapons, so as to make Xiaoyu's combat power more powerful
That is to find a set of solutions $$Xi $$($$1 $$< = $$I $$< = $$n $$, and $$Xi $$= $$0 $$or $$1 $$) such that $$\ sum_{ i=1}^n ai*xi/\sum_{ I = 1} ^ n bi * Xi $$is the largest, and there are exactly $$k $$$Xi $$as $$1 $$
Please output the maximum value
###Input format:
In the first line, two positive integers, $$n $$and $$k $. Indicate that Xiaoyu wants to select $$k $$of the $$n $$weapons
In the second line, $$n $$positive integers represent $$A1 $$, $$A2 $$, $$an$$
In the third line, $$n $$positive integers represent $$B1 $$, $$B2 $$, $$BN$$
1<=$$k$$<=$$n$$<=$$10^5$$ ,1<=$$ai$$<=$$bi$$<=$$10^6$$
###Output format:
Output a real number, accurate to 4 decimal places
###Input example:
Here is a set of inputs. For example:
```in
3 2
5 0 2
5 1 6
```
###Output example:
The corresponding output is given here. For example:
```out
zero point eight three three three
```







answer:If there is no answer, please comment