Maximize the Minimum
Time limit4sMemory limit2048 MB
Given two arrays with per-element removal costs, find the largest possible minimum gap |a_i - b_j| across the remaining elements when total removal cost is at most s.
- Level
Hard8 of 10
- Topics
- Binary search, Dynamic programming, Sorting
- Solved
- No attempts yet
Problem
You have an array of length and an array of length . You can choose to remove some elements from the arrays. Removing element costs coins, and removing element costs coins. Importantly, there should be at least one element left in and at least one left in .
When you are done removing the elements, you compute the following value:
You want to maximize this value. What is the maximum value you can get if you can spend at most coins in total?
Input
The first line contains an integer (), the number of test cases. The test cases follow.
The first line of each test case contains integers (), () and (). The next four lines contain integer arrays , , , , in this order (; ). The arrays and have length . The arrays and have length .
The sum of over all test cases does not exceed . The sum of over all test cases does not exceed .
Output
For each test case, print the maximum possible value you can get.