#include #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) using ll = std::int64_t; using P = std::tuple; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int N; std::cin >> N; std::vector

p(N); for(int i=0;i> x >> y; p[i] = std::make_tuple(x + y, x - y); } int M; std::cin >> M; std::vector

q(M); for(int i=0;i> x >> y; q[i] = std::make_tuple(x + y, x - y); } std::sort(std::begin(q), std::end(q)); int numLeaves = 1; while(M > numLeaves){numLeaves *= 2;} std::vector> seg(numLeaves * 2); for(int i=0;i0;i--){ std::merge( std::begin(seg[i * 2]), std::end(seg[i * 2]), std::begin(seg[i * 2 + 1]), std::end(seg[i * 2 + 1]), std::back_inserter(seg[i]) ); } int res = 3000; for(int i=0;i 1){ int m = (ok + ng) / 2; int lx = std::upper_bound(std::begin(q), std::end(q), std::make_tuple(xp - m, std::numeric_limits::min())) - std::begin(q); lx += numLeaves; int rx = std::lower_bound(std::begin(q), std::end(q), std::make_tuple(xp + m, std::numeric_limits::min())) - std::begin(q); rx += numLeaves; bool can = true; for(;lx