/* Someday at the sound of the night blooming Simply take away the loneliness from me Well then, goodbye, my drifting emotions I'll close my eyes and have a good night. See you tomorrow At the moment, it's just a little bit hard I won't cry or something, I'm just trying to walk it off I don't know what will be on my mind a few minutes later, and I still won't know even today Wobbly, Wobbly, Wobbly, Wobbly floating Ah, I'm such a bad child. An inferior student Is that okay? Is that really okay? I can't laugh well today, is that okay? Are you ready? Hey! I said "are you ready?" Let's just doze off into the warm corners of the night Is that okay? Ah, Is that really okay? I don't know what to say, is that okay? Like that, come on, just like that I'll dance with you, lalulalila~ See you later Credits:- MIMI Song:- Escape */ // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include //#include //#include #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define show(x) cout << (#x) << " : " << x << endl; //typedef __int128 bigll; typedef long long ll; #define ull unsigned long long #define ld long double #define pow power #define mp make_pair #define ff first #define ss second #define pii pair #define pll pair #define sq(x) ((x) * (x)) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define siz(a) int((a).size()) #define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i)) #define Forl(i,a,b) for(ll (i)=(a);(i) < (b); ++(i)) #define Forn(i,a,b) for(int (i)=(a);(i) >= (b); --(i)) #define Fornl(i,a,b) for(ll (i)=(a);(i) >= (b); --(i)) #define endl "\n" #define pi 3.14159265 #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) const ll mod = 1000 * 1000 * 1000 + 7; const ll mod1 = 998244353; const ll INF = 1ll*1000*1000*1000*1000*1000*1000 + 7; //using namespace __gnu_pbds; using namespace std; //typedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //typedef tree,null_type,less>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; ll power(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (long long)(res*x); // adding powers wherever bit is set y = y>>1; x = (long long)(x*x); // increasing power by 2 //cout< ostream& operator <<(ostream& ostream, pair& p) { cout << p.first << " " << p.second; return ostream; } template ostream& operator <<(ostream& ostream, vector& v) { for(auto& element : v) { cout << element << " "; } return ostream; } template ostream& operator <<(ostream& ostream, vector>& v) { for(auto& row : v) { for(auto& cell : row) { cout << cell << " "; } cout << "\n"; } return ostream; } template istream& operator >>(istream& istream, pair& p) { cin >> p.first >> p.second; return istream; } template istream& operator >>(istream& istream, vector& v) { for(auto& element : v) { cin >> element; } return istream; } void print() { cout << endl; } template void print(const T& t) { cout << t << endl; } template void print(const First& first, const Rest&... rest) { cout << first << " "; print(rest...); // recursive call using pack expansion syntax } void dbg() { cerr << endl; } template void dbg(const T& t) { cerr << t << endl; } template void dbg(const First& first, const Rest&... rest) { cerr << first << " "; dbg(rest...); // recursive call using pack expansion syntax } // Stolen Templates end here // ostream& operator << (ostream&, bigll val) { // string temp; // while (val > 0) { temp.pb(val % 10 + '0'); val /= 10; } // for(int i = siz(temp) - 1; i >= 0; i--)cout<> (istream&, bigll & val) { // string temp; cin>>temp; val = 0; // for(int i = 0; i < siz(temp); i++)val = val * 10 + temp[i] - '0'; // return cin; // } // for cin we use & because we want the original object we are sending not a copy of it int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif // If you plan on using set / map do check if it will TLE or not fastio(); ll n; cin>>n; vector a(n),b(n); cin>>a>>b; vector vux; For(i,0,n) { if (a[i] > b[i])swap(a[i], b[i]); vux.pb(a[i]); vux.pb(b[i]); vux.pb((a[i] + b[i]) / 2); } sort(all(vux)); ll m = siz(vux); ll req = vux[m / 2]; set fin; For(i,0,n) { //ll to_insert = 0; //to_insert = a[i]; vector temp; temp.pb({abs(a[i] - req), 0}); temp.pb({abs(b[i] - req), 2}); temp.pb({abs((a[i] + b[i]) / 2 - req), 1}); sort(all(temp)); if (temp[0].ss == 0)fin.insert(a[i]); if (temp[0].ss == 1)fin.insert((a[i] + b[i]) / 2); if (temp[0].ss == 2)fin.insert(b[i]); } cout<<*fin.rbegin() - *fin.begin(); return 0; } // check all product based operations for integer overflow // careful of renamed variables especially in loops //python interactive_runner.py python local_testing_tool.py 0 -- c.exe