592. Minimum Cost to Hire K Workers

0

Hard

There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.
We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:
Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
Every worker in the paid group must be paid at least their minimum wage expectation.
Given the integer k, print the least amount of money needed to form a paid group satisfying the above conditions.

Input Format

First line contains size of first array

Second line contains first array

Third line contains size of second array

Fourth line contains second array

Fifth line contains K

Second line contains first array

Third line contains size of second array

Fourth line contains second array

Fifth line contains K

Output Format

print the least amount of money needed to form a paid group satisfying the above conditions.

Example

Input

3
10 20 5
3
70 50 30

Output

105.0

Constraints

n == quality.length == wage.length

1 <= k <= n <= 10

1 <= quality[i], wage[i] <= 10

1 <= k <= n <= 10

^{4}1 <= quality[i], wage[i] <= 10

^{4}Loading...

View Submissions

Console