当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3309:Unlucky Luke!

题目描述

The great Lucky Luke and his smart horse Jolly Jumper are again caught the four evil Dalton brothers and sent them to the prison. As a reward, the governor of the province in which the Daltons had been caught, gave a collection of gold stones to Luke. At first, Luke became very happy for obtaining such a treasure, but he remembered he had a limited space to carry these stones. In fact, he can just count on the kyack on the back of Jolly which consists of two bags with volume V on either side of Jolly’s packsaddle. As a result, he cannot carry all the stones and must take just some of them.

He thought, "At least, I can use as much space as possible in the Jolly's kyack by taking a portion of some of the stones with myself." But Unlucky Luke found that all smiths, instead of their wage for cutting the portion of a stone that he wants, will take the left portion of the stone (for example, if Luke gives the smith one stone and asks him to cut and give him 20% of it, the smith will take the remaining 80% as his wage). What an unfair deal! They know Luke is rich now and will not change their mind! Now, Luke wants to select a portion of each stone in a way that he could place them in two bags in his kyack without exceeding their volume and the selected stones have the maximum total value. Unfortunately, Luke that fires a gun faster than his shadow (see the picture below for the proof of this claim!) can not solve this problem and needs your help! It should be noted that a portion with p% of a stone volume has p% of its value.

输入解释

Input begins with a number T showing the number of test cases and then, T test cases follow. Each test case begins with a line containing an integer 1 ≤ n ≤100 and a positive real number V ≤ 5000 representing the number of stones and volume of each bag respectively. After that, a line containing n positive integers less than or equal to 100 will come where the ith number shows the volume of ith gold stone. Then, a line containing n positive real numbers will come where the ith number shows the value of ith gold stone.

输出解释

For each test case, your program must output the maximum total value of stones which can be carried by Luke rounded to four digits after the decimal point.

输入样例
1
4 10.0
6 7 8 9
10.0 12.0 14.0 16.0
输出样例
35.0952

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3309

最后修改于 2020-10-29T06:58:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536