#include #include #include #include using namespace std; using ll = long long; int f(vector s, vector t){ multiset stand; for(auto p:s) stand.insert(p); int m=t.size(); for(int i=0; i> n >> m; vector s(n), t(m); multiset stand; for(auto& p:s) cin >> p, stand.insert(p); for(auto& p:t) cin >> p; int maxi=f(s, t); //cout << maxi << endl; if(maxi==0){ cout << 0 << endl; return 0; } vector tt; for(int i=0; i1){ int mid=(left+right)/2; multiset S=stand; bool ok=true; for(auto p:tt){ auto q=S.upper_bound(p+mid); if(q==S.begin()){ok=false; break;} auto r=prev(q); if((*r)>=p) S.erase(r); else{ok=false; break;} } if(ok) right=mid; else left=mid; } cout << right << endl; return 0; }