#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define FOR(i, a, b) for (signed ll i = (signed ll)(a); i < (signed ll)(b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<ll>
#define sll set<ll>
#define ld long double
#define inf 10000000005
#define mll multiset<ll>
#define vpll vector<pll>
#define nn << "\n"
#define ss << " "
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18
ll l, r;
mll le, ri;
bool check(ll n)
{
mll x=le;
mll y=ri;
if (l > r)
{
swap(l, r);
swap(x, y);
}
for (auto i:x){
auto it=y.lower_bound(i-n);
if (abs(*it-i)<=n){
// if (n==0) cout<<*it-i ss;
y.erase(it);
}
else return 0;
}
return 1;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> l >> r;
FOR(i, 0, l)
{
ll a;
cin >> a;
le.insert(a);
}
FOR(i, 0, r)
{
ll a;
cin >> a;
ri.insert(a);
}
ll l=-1, r=inf;
while (check(r)){
ll mid=l+(r-l)/2;
//cout<<mid <<endl;
if (check(mid)){
r=mid-1;
//if (r==0) cout<<"yes";
}
else{
l=mid+1;
}
}
cout<<r+1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1101 ms |
19052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
19052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
748 KB |
Output is correct |
2 |
Correct |
50 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
876 KB |
Output is correct |
2 |
Correct |
50 ms |
1332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1132 KB |
Output is correct |
2 |
Correct |
52 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1192 KB |
Output is correct |
2 |
Correct |
50 ms |
1292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
1388 KB |
Output is correct |
2 |
Correct |
49 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
15592 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
17092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
15212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |