提交时间:2026-05-29 19:42:16

运行 ID: 41765

#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while(t--){ int n; cin>>n; vector<ll> a(n),b(n); for(auto &x:a)cin>>x; for(auto &x:b)cin>>x; sort(a.begin(),a.end()); sort(b.begin(),b.end()); ll res=0; for(int k=0;k<n;k++){ ll mn=LLONG_MAX; for(int i=0;i<n;i++){ int j=(i+k)%n; mn=min(mn,abs(a[i]-b[j])); if(mn<=res) break; } res=max(res,mn); } cout<<res<<'\n'; } }