Maximize the Minimum

시간 제한4초메모리 제한2048 MB

요약
예산 안에서 원소 일부를 제거한 뒤 남은 a와 b 사이 최소 절댓값 차이를 최대한 크게 만드는 값을 구한다.
난이도

어려움10점 중 8점

유형
정렬, 이분 탐색, 그리디, 누적 합
정답자
아직 제출이 없습니다

문제

You have an array aa of length nn and an array bb of length mm. You can choose to remove some elements from the arrays. Removing element a_ia\_i costs c_ic\_i coins, and removing element b_jb\_j costs d_jd\_j coins. Importantly, there should be at least one element left in aa and at least one left in bb.

When you are done removing the elements, you compute the following value:

min⁡_1≤i≤n 1≤j≤m∣a_i−b_j∣.\min\limits\_{\substack{1 \le i \le n \\\ 1 \le j \le m}} |a\_i - b\_j|\text{.}

You want to maximize this value. What is the maximum value you can get if you can spend at most ss coins in total?

입력

The first line contains an integer tt (1≤t≤2⋅1051 \le t \le 2 \cdot 10^5), the number of test cases. The test cases follow.

The first line of each test case contains integers nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5), mm (1≤m≤2⋅1051 \le m \le 2 \cdot 10^5) and ss (0≤s≤10180 \le s \le 10^{18}). The next four lines contain integer arrays aa, bb, cc, dd, in this order (−109≤a_i,b_j≤109-10^9 \le a\_i, b\_j \le 10^9; 1≤c_i,d_j≤10121 \le c\_i, d\_j \le 10^{12}). The arrays aa and cc have length nn. The arrays bb and dd have length mm.

The sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5. The sum of mm over all test cases does not exceed 2⋅1052 \cdot 10^5.

출력

For each test case, print the maximum possible value you can get.

예제1

  1. 예제 1

    입력
    2
    1 4 10
    15
    1 6 9 13
    8
    3 1 2 4
    5 4 4
    -1 5 3 2 -4
    -7 8 6 2
    2 3 1 1 2
    3 1 1 1
    
    예상 출력
    14
    3