Logo
(追記) (追記ここまで)

33587번 - Charming Meals 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 2048 MB20171789.474%

문제

The Czech cuisine features $n$ appetizers and $n$ main dishes. The $i$-th appetizer has spiciness $a_i,ドル and the $i$-th main dish has spiciness $b_i$.

A typical Czech meal consists of exactly one appetizer and one main dish. You want to pair up the $n$ appetizers and $n$ main dishes into $n$ 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 $x$ and a main dish with spiciness $y$ has charm equal to $|x - y|$.

You want to maximize the minimum charm of the resulting $n$ 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 $t$ (1ドル ≤ t ≤ 1,円 000$) — the number of test cases. The descriptions of the $t$ test cases follow.

The first line of each test case contains a single integer $n$ (1ドル ≤ n ≤ 5,円 000$) —the number of appetizers and main dishes.

The second line of each test case contains $n$ integers $a_1, a_2, \dots , a_n$ (0ドル ≤ a_i ≤ 10^9$) — the spicinesses of the $n$ appetizers.

The third line of each test case contains $n$ integers $b_1, b_2, \dots , b_n$ (0ドル ≤ b_i ≤ 10^9$) — the spicinesses of the $n$ main dishes.

It is guaranteed that the sum of $n^2$ over all test cases does not exceed 25ドル \cdot 10^6$.

출력

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

제한

예제 입력 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

예제 출력 1

1000000000
2
100
30

In the first test case, no matter how you pair up the appetizers with the main dishes, each meal will have an appetizer with spiciness 0ドル$ and a main dish with spiciness 1000000000ドル,ドル so the charm of each meal will be 1000000000ドル$.

In the second test case, one optimal way to pair up appetizers and main dishes is: $(1, 5),ドル $(2, 4),ドル $(3, 1),ドル $(4, 2),ドル $(5, 3)$. The corresponding meals have charms: 4ドル,ドル 2ドル,ドル 2ドル,ドル 2ドル,ドル 2ドル$. The resulting minimum charm is 2ドル$.

In the third test case, one way to maximize the minimum charm is to pair up the three appetizers with spiciness 0ドル$ with the three main dishes with spiciness 100ドル,ドル and the three appetizers with spiciness 100ドル$ with the three main dishes with spiciness 0ドル$. Doing so, the charm of each meal will be exactly 100ドル$.

힌트

출처

ICPC > Regionals > Europe > European Championship > The 2024 ICPC European Championship B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /