| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 41782 | pljplj | 【S】T2 | C++ | 解答错误 | 0 | 631 MS | 5588 KB | 1148 | 2026-05-29 19:59:48 |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e5 + 5; ll a[MAXN], b[MAXN]; int n; bool check(ll v) { queue<int> q; int j = 1; for (int i = 1; i <= n; ++i) { while (j <= n && b[j] <= a[i] - v) { q.push(j); j++; } if (!q.empty()) { q.pop(); continue; } while (j <= n && b[j] < a[i] + v) j++; if (j > n) return false; j++; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) cin >> b[i]; sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); ll L = 0, R = 1e9, ans = 0; while (L <= R) { ll mid = (L + R) >> 1; if (check(mid)) { ans = mid; L = mid + 1; } else { R = mid - 1; } } cout << ans << '\n'; } return 0; }