Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
41766 pljplj 【S】T2 C++ 解答错误 0 547 MS 4960 KB 971 2026-05-29 19:42:44

Tests(0/6):


#include <bits/stdc++.h> using namespace std; using ll = long long; int n; vector<ll> a, b; bool check(ll d) { int cnt = 0; int j = 0; for (int i = 0; i < n; i++) { while (j < n && b[j] < a[i] - d) j++; if (j < n && b[j] <= a[i] + d) j++; else cnt++; } return cnt == 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { cin >> n; a.resize(n); b.resize(n); for (auto &x : a) cin >> x; for (auto &x : b) cin >> x; sort(a.begin(), a.end()); sort(b.begin(), b.end()); ll l = 0, r = 1e9, ans = 0; while (l <= r) { ll mid = (l + r) / 2; if (check(mid)) { ans = mid; l = mid + 1; } else { r = mid - 1; } } cout << ans << '\n'; } return 0; }


测评信息: