编程介的小学生 2017-07-25 12:33 采纳率: 0.2%
浏览 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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化