Charming Meals

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

요약
각 전채를 하나의 메인 요리와 짝지어 모든 식사에서 가장 작은 매운맛 차이의 절댓값을 최대로 만든다.
난이도

어려움10점 중 8점

유형
정렬, 이분 탐색, 그리디, 투 포인터
정답자
아직 제출이 없습니다

문제

The Czech cuisine features nn appetizers and nn main dishes. The ii-th appetizer has spiciness a_ia\_i, and the ii-th main dish has spiciness b_ib\_i.

A typical Czech meal consists of exactly one appetizer and one main dish. You want to pair up the nn appetizers and nn main dishes into nn meals with each appetizer and each main dish being included in exactly one meal.

Your meals shall surprise the diners, so you want the spiciness levels of the two parts of the same meal to be as different as possible. The charm of a meal is the difference (in absolute value) between the spiciness of the appetizer and the spiciness of the main dish. So, a meal consisting of an appetizer with spiciness xx and a main dish with spiciness yy has charm equal to ∣x−y∣|x - y|.

You want to maximize the minimum charm of the resulting nn meals. What is the largest possible value of the minimum charm that you can achieve?

입력

Each test contains multiple test cases. The first line contains an integer tt (1≤t≤1,0001 ≤ t ≤ 1\\, 000) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains a single integer nn (1≤n≤5,0001 ≤ n ≤ 5\\, 000) —the number of appetizers and main dishes.

The second line of each test case contains nn integers a_1,a_2,…,a_na\_1, a\_2, \dots , a\_n (0≤a_i≤1090 ≤ a\_i ≤ 10^9) — the spicinesses of the nn appetizers.

The third line of each test case contains nn integers b_1,b_2,…,b_nb\_1, b\_2, \dots , b\_n (0≤b_i≤1090 ≤ b\_i ≤ 10^9) — the spicinesses of the nn main dishes.

It is guaranteed that the sum of n2n^2 over all test cases does not exceed 25⋅10625 \cdot 10^6.

출력

For each test case, print the largest possible value of the minimum charm you can achieve.

예제1

  1. 예제 1

    입력
    4
    3
    0 0 0
    1000000000 1000000000 1000000000
    5
    1 2 3 4 5
    1 2 3 4 5
    6
    0 0 0 100 100 100
    100 100 100 0 0 0
    7
    14 25 62 74 86 95 12
    51 62 71 72 92 20 84
    
    예상 출력
    1000000000
    2
    100
    30