编程介的小学生 2017-07-25 12:33 采纳率: 20.5%
浏览 712
已采纳

Unlucky Luke!

escription

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

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.

Output

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.

Sample Input

1
4 10.0
6 7 8 9
10.0 12.0 14.0 16.0
Sample Output

35.0952

  • 写回答

1条回答 默认 最新

  • devmiao 2017-08-12 14:57
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探